function [ mu, var ] = permutation_distance_stats ( m, n )

%*****************************************************************************80
%
%% permutation_distance_stats() estimates permutation distance statistics.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 September 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the permutation order.
%
%    integer N, the number of samples to consider.
%
%  Output:
%
%    real MU, VAR, the estimated mean and variance of the
%    distance between two random permutations of order N.
%
  t = zeros ( n, 1 );

  for i = 1 : n
    p1 = randperm ( m );
    p2 = randperm ( m );
    t(i) = permutation_distance_ulam ( p1, p2 );
  end

  mu = sum ( t(1:n) ) / n;
  if ( 1 < n )
    var = sum ( ( t(1:n) - mu ) .^ 2 ) / ( n - 1 );
  else
    var = 0.0;
  end

  return
end
 
