function triangle_equilateral_distance_pdf_test ( )

%*****************************************************************************80
%
%% triangle_equilateral_distance_pdf_test() tests triangle_equilateral_distance_pdf().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 March 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'triangle_equilateral_distance_pdf_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test triangle_equilateral_distance_pdf,\n' );
  fprintf ( 1, '  probability density function for the distance D between\n' );
  fprintf ( 1, '  between a pair of random points in an equilateral triangle.\n' );

  v = [ 0.0,   0.0; ...
        1.0,   0.0; ...
        0.500, sqrt(3)/2.0 ];
  triangle_print ( v, '  Triangle vertices:' );
  [ a, b, c ] = triangle_sides ( v );
  d = linspace ( 0.0, c, 101 );
  pdf = triangle_equilateral_distance_pdf ( d );

  figure ( );
  clf ( );
  plot ( d, pdf, 'r-', 'linewidth', 2 );
  grid ( 'on' );
  xlabel ( '<-- X = Distance -->' );
  ylabel ( '<-- Y = PDF(X) -->' );
  title ( 'PDF for distance between random points in equilateral triangle' );
  filename = 'triangle_equilateral_distance_pdf.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  pause ( 5 );

  figure ( );
  clf ( );
  hold ( 'on' );
  n = 10000;
  triangle_distance_histogram ( v, n );
  plot ( d, pdf, 'r-', 'linewidth', 2 );
  grid ( 'on' );
  xlabel ( '<-- X = Distance -->' );
  ylabel ( '<-- Y = PDF(X) -->' );
  title ( 'PDF and histogram for pairwise distance in equilateral triangle' );
  hold ( 'off' );
  filename = 'triangle_equilateral_distance_compare.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
  pause ( 5 );

  return
end
