function subset_distance_test ( )

%*****************************************************************************80
%
%% subset_distance_test() tests subset_distance().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 January 2021
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../subset_distance' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'subset_distance_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test subset_distance().\n' );

  m = 16;
  n = 10000;
  [ mu, var ] = subset_distance_stats ( m, n );
  mu_exact = m / 2;
  var_exact = m / 4.0;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Master set size = %d\n', m );
  fprintf ( 1, '  Using N = %d sample points,\n', n );
  fprintf ( 1, '  Estimated mean distance = %g\n', mu );
  fprintf ( 1, '  Exact mean distance     = %g\n', mu_exact );
  fprintf ( 1, '  Estimated variance      = %g\n', var );
  fprintf ( 1, '  Exact variance          = %g\n', var_exact );

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

  subset_distance_pdf ( m );
  filename = 'subset_distance_pdf.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );

  clf ( );
  hold ( 'on' );
  n = 10000;
  subset_distance_histogram ( m, n );
  subset_distance_pdf ( m );
  hold ( 'off' );
  filename = 'subset_distance_compare.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'subset_distance_test()::\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../subset_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

