function normal01_multivariate_distance_test ( )

%*****************************************************************************80
%
%% normal01_multivariate_distance_test tests normal01_multivariate_distance.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    07 February 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../normal01_multivariate_distance' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'normal01_multivariate_distance_test:\n' );
  fprintf ( 1, '  MATLAB version\n' );
  fprintf ( 1, '  Test normal01_multivariate_distance.\n' );

  randn_test ( );

  m = 10;
  n = 10000;
  [ mu, var ] = normal01_multivariate_distance_stats ( m, n );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Using N = %d sample points,\n', n );
  fprintf ( 1, '  Estimated mean distance = %g\n', mu );
  fprintf ( 1, '  Estimated variance      = %g\n', var );

  m = 10;
  n = 10000;
  normal01_multivariate_distance_histogram ( m, n );
  filename = 'normal01_multivariate_distance_histogram.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
  pause ( 5 );

  m_max = 50;
  x = zeros ( m_max, 1 );
  y = zeros ( m_max, 1 );
  n = 1000;

  for m = 1 : m_max
    [ mu, var ] = normal01_multivariate_distance_stats ( m, n );
    x(m) = m;
    y(m) = mu;
  end

  figure ( )
  clf
  hold on
  plot ( x, y, 'bo', 'Linewidth', 3 );
  plot ( x, sqrt ( 2.0 * x ), 'r-', 'Linewidth', 3 );
  xlabel ( '<-- Spatial dimension -->' );
  ylabel ( '<-- Average distance -->' );
  title ( 'Average distance between multivariate normal01 samples' );
  grid ( 'on' );
  hold off
  filename = 'normal01_multivariate_distance_plot.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'normal01_multivariate_distance_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../normal01_multivariate_distance' );

  return
end

