function [ x, rank ] = mono_between_random ( m, n1, n2 )

%*****************************************************************************80
%
%% mono_between_random(): random monomial with total degree between N1 and N2.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 July 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the spatial dimension.
%
%    integer N1, N2, the minimum and maximum degrees.
%    0 <= N1 <= N2.
%
%  Output:
%
%    integer X(M), the random monomial.
%
%    integer RANK, the rank of the monomial.
%
  n1_copy = max ( n1, 0 );
  rank_min = mono_upto_enum ( m, n1_copy - 1 ) + 1;
  rank_max = mono_upto_enum ( m, n2 );
  rank = randi ( [ rank_min, rank_max ], 1 );
  x = mono_unrank_grlex ( m, rank );

  return
end
