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

%*****************************************************************************80
%
%% mono_total_random(): random monomial with total degree equal to N.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 July 2021
%
%  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 = mono_upto_enum ( m, n - 1 ) + 1;
  rank_max = mono_upto_enum ( m, n );
  rank = randi ( [ rank_min, rank_max ], 1 );
  x = mono_unrank_grlex ( m, rank );

  return
end
