function box_distance_test ( )

%*****************************************************************************80
%
%% box_distance_test() tests box_distance().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    19 May 2023
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../box_distance' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'box_distance_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test box_distance().\n' );
%
  a = 1.0;
  b = 1.0;
  c = 1.0;
  mu_exact = box_distance_mean ( a, b, c );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  For a = b = c, box_distance_mean() should be 0.661707182...\n' );
  fprintf ( 1, '  Computed value was %g\n', mu_exact );
%
  n = 10000;
  a = 1.0;
  b = 1.0;
  c = 1.0;
  [ mu, var, moment2 ] = box_distance_stats ( n, a, b, c );
  mu_exact = box_distance_mean ( a, b, c );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Using N = %d sample points,\n', n );
  fprintf ( 1, '  Short   box side a =  %g\n', a );
  fprintf ( 1, '  Medimum box side b =  %g\n', b );
  fprintf ( 1, '  Long    box side c =  %g\n', c );
  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, '  Estimated second moment = %g\n', moment2 );
  fprintf ( 1, '  Exact second moment     = %g\n', ( a^2 + b^2 + c^2 ) / 6.0 );
%
  n = 10000;
  a = 1.0;
  b = 3.0;
  c = 5.0;
  [ mu, var, moment2 ] = box_distance_stats ( n, a, b, c );
  mu_exact = box_distance_mean ( a, b, c );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Using N = %d sample points,\n', n );
  fprintf ( 1, '  Short   box side a =  %g\n', a );
  fprintf ( 1, '  Medimum box side b =  %g\n', b );
  fprintf ( 1, '  Long    box side c =  %g\n', c );
  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, '  Estimated second moment = %g\n', moment2 );
  fprintf ( 1, '  Exact second moment     = %g\n', ( a^2 + b^2 + c^2 ) / 6.0 );
#
  n = 10000;
  a = 1.0;
  b = 3.0;
  c = 5.0;
  box_distance_histogram ( n, a, b, c );
  filename = 'box_distance_histogram.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'box_distance_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

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

