function ball_distance_test ( )

%*****************************************************************************80
%
%% ball_distance_test tests ball_distance.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    17 April 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../ball_distance' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ball_distance_test:\n' );
  fprintf ( 1, '  MATLAB version\n' );
  fprintf ( 1, '  Test ball_distance.\n' );

  n = 10000;
  [ mu, var ] = ball_distance_stats ( n );
  mu_exact = 36.0 / 35.0;
  fprintf ( 1, '\n' );
  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 );

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

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

  clf
  hold on
  n = 10000;
  ball_distance_histogram ( n );
  ball_distance_pdf ( );
  hold off
  filename = 'ball_distance_compare.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ball_distance_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../ball_distance' )

  return
end
