function fly_cdf_plot ( n )

%*****************************************************************************80
%
%% fly_cdf_plot() plots the estimated CDF for the fly simulation.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    11 August 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer n: the number of times the experiment is carried out.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'fly_cdf_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 CDF for D with a plot.\n' );

  d = fly_simulation ( n );
%
%  Plot a histogram.
%
  clf ( );
  hold ( 'on' );
  h = cdfplot ( d );
  set ( h, 'linewidth', 3 );
  grid ( 'on' );
  title ( 'CDF for fly simulation' );
  xlabel ( '<-- Distance from center -->' );
  ylabel ( '<-- Probability -->' );
  d2 = linspace ( 0.0, 1.0, 21 );
  plot ( d2, d2.^2, 'ro', 'linewidth', 3 );
  hold ( 'off' );
  legend ( 'Observed CDF', 'Exact CDF' );
  filename = 'fly_cdf.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

