function [ x, rank ] = mono_upto_random ( m, n )

%*****************************************************************************80
%
%% mono_upto_random(): random monomial with total degree less than or equal to N.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 September 2014
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the spatial dimension.
%
%    integer N, the degree.
%    0 <= N.
%
%  Output:
%
%    integer X(M), the random monomial.
%
%    integer RANK, the rank of the monomial.
%
  rank_min = 1;
  rank_max = mono_upto_enum ( m, n );
  rank = randi ( [ rank_min, rank_max ], 1 );
  x = mono_unrank_grlex ( m, rank );

  return
end
