function hypercube_distance_histogram ( m, n )

%*****************************************************************************80
%
%% hypercube_distance_histogram() histograms hypercube distance statistics.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 November 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the spatial dimension.
%
%    integer N, the number of samples to use.
%
  t = sqrt ...
  ( sum ...
    ( ...
      ( rand ( m, n ) - rand ( m, n ) ).^2 ...
    ) ...
  );

  bin_num = 40;
  h = sqrt ( m ) / bin_num / 2.0;
  bins = linspace ( 0.0 + h, sqrt ( m ) - h, bin_num );
  normalization = bin_num / sqrt ( m );
  hist ( t, bins, normalization );
  grid ( 'on' );
  xlabel ( '<-- Distance -->' );
  ylabel ( '<-- Frequency -->' );
  title_string = sprintf ( ...
    'Distance between random points in a unit %d cube', m );
  title ( title_string );

  return
end
