function normal01_multivariate_distance_test ( )

%*****************************************************************************80
%
%% normal01_multivariate_distance_test() tests normal01_multivariate_distance().
%
%  Licensing:
%
%    This code is distributed under the MIT 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/Octave version %s\n', version ( ) );
  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 );
  pause ( 5 );

  if ( false )
    m = 10;
    normal01_multivariate_distance_plot ( m );
    pause ( 5 );
  else
    fprintf ( 1, '\n' );
    fprintf ( 1, '  normal01_multivariate_distance_plot() requires\n' );
    fprintf ( 1, '  access to the Statistics and Machine Learning Toolbox.\n' );
    fprintf ( 1, '  This test is CANCELLED.\n' );
  end

  if ( false )
    m = 10;
    n = 10000;
    normal01_multivariate_distance_compare ( m, n );
    pause ( 5 );
  else
    fprintf ( 1, '\n' );
    fprintf ( 1, '  normal01_multivariate_distance_compare() requires\n' );
    fprintf ( 1, '  access to the Statistics and Machine Learning Toolbox.\n' );
    fprintf ( 1, '  This test is CANCELLED.\n' );
  end

  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

  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, '  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
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

