function normal01_multivariate_distance_compare ( m, n )

%*****************************************************************************80
%
%% normal01_multivariate_distance_compare compares multivariate normal distance PDFs.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 May 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the spatial dimension.
%
%    integer N, the number of samples to use.
%
  t = zeros ( n, 1 );
  for i = 1 : n
    p = randn ( m, 1 );
    q = randn ( m, 1 );
    t(i) = norm ( p - q );
  end

  clf ( );
  hold ( 'on' )
  bins = 20;
  histogram ( t.^2, bins, 'Normalization', 'pdf' );
  x = linspace ( 0, 0.5*m^2, 101 );
  y = 0.5 * chi2pdf ( 0.5*x, m );

  plot ( x, y, 'r-' );
  grid ( 'on' );
  xlabel ( '<-- Distance -->' )
  ylabel ( '<-- Relative frequency -->' )
  label = sprintf ( 'Compare observed and theoretical PDF for %d-dimensional normal01 samples', m );
  title ( label )
  hold ( 'off' )
  filename = 'normal01_multivariate_distance_compare.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
