function triangle_distance_stats_test ( )

%*****************************************************************************80
%
%% triangle_distance_stats_test() tests triangle_distance_stats().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 April 2019
%
%  Author:
%
%    John Burkardt
%
  n = 10000;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'triangle_distance_stats_test\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test triangle_distance_stats.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of sample points N = %d\n', n );
%
%  Equilateral triangle with side 1.
%
  v = [ ...
    0.00, 0.00;...
    1.00, 0.00; ...
    0.500, sqrt(3.0)/2.0 ];

  triangle_print ( v,  '  Equilateral triangle vertices:' );

  [ mu, var ] = triangle_distance_stats ( v, n );
  mu_exact = 0.2 + 3.0 * log ( 3.0 ) / 20.0;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Estimated mu  = %g\n', mu );
  fprintf ( 1, '  Exact mu      = %g\n', mu_exact );
  fprintf ( 1, '  Estimated var = %g\n', var );
%
%  Unit right triangle.
%
  v = [ ...
    0.00, 0.00;...
    1.00, 0.00; ...
    0.00, 1.00 ];

  triangle_print ( v, '  Unit right triangle vertices:' );

  [ mu, var ] = triangle_distance_stats ( v, n );
  mu_exact = ( 2.0 + 4.0 * sqrt ( 2.0 ) ...
    + ( 4.0 + sqrt ( 2.0 ) ) * asinh ( 1.0 ) ) / 30.0;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Estimated mu  = %g\n', mu );
  fprintf ( 1, '  Exact mu      = %g\n', mu_exact );
  fprintf ( 1, '  Estimated var = %g\n', var );
%
%  345 right triangle.
%
  v = [ ...
    0.00, 0.00;...
    3.00, 0.00; ...
    0.00, 4.00 ];

  triangle_print ( v, '  345 right triangle Vertices:' );

  [ mu, var ] = triangle_distance_stats ( v, n );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Estimated mu  = %g\n', mu );
  fprintf ( 1, '  Estimated var = %g\n', var );
%
%  scalene triangle.
%
  v = [ ...
    0.75, 0.90;...
    0.00, 0.20; ...
    0.95, 0.65 ];

  triangle_print ( v, '  scalene triangle Vertices:' );

  [ mu, var ] = triangle_distance_stats ( v, n );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Estimated mu  = %g\n', mu );
  fprintf ( 1, '  Estimated var = %g\n', var );

  return
end
