function fly_pdf_plot ( n )

%*****************************************************************************80
%
%% fly_pdf_plot() plots the estimated PDF for the fly simulation.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    22 July 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer n: the number of times the experiment is carried out.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'fly_pdf_plot()\n' );
  fprintf ( 1, '  A fly lands at random on a plate of radius 1.\n' );
  fprintf ( 1, '  D is the distance from the center.\n' );
  fprintf ( 1, '  Estimate the PDF for D with a plot.\n' );

  d = fly_simulation ( n );
%
%  Plot a histogram.
%
  clf ( );
  hold ( 'on' );
  histogram ( d, 'normalization', 'pdf' );
  grid ( 'on' );
  title ( 'PDF for fly simulation' );
  xlabel ( '<-- Distance from center -->' );
  ylabel ( '<-- Probability -->' );
  d2 = linspace ( 0.0, 1.0, 101 );
  plot ( d2, 2.0 * d2, 'r-', 'linewidth', 3 );
  hold ( 'off' )

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

  return
end

