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

%*****************************************************************************80
%
%% hypercube_distance_stats estimates hypercube distance statistics.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 January 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the spatial dimension.
%
%    integer N, the number of sample points to use.
%
%  Output:
%
%    real MU, VAR, the estimated mean and variance of the
%    distance between two random points in the unit hypercube.
%
  t = sqrt ...
  ( sum ...
    ( ...
      ( rand ( m, n ) - rand ( m, n ) ).^2 ...
    ) ...
  );

  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
