function flies_cdf_plot ( n )

%*****************************************************************************80
%
%% flies_cdf_plot() plots the estimated CDF for the flies simulation.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    09 August 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer n: the number of times the experiment is carried out.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'flies_cdf_plot()\n' );
  fprintf ( 1, '  Two flies land at random on a plate of radius 1.\n' );
  fprintf ( 1, '  D is the distance between them.\n' );
  fprintf ( 1, '  Estimate the CDF for D with a plot.\n' );

  d = flies_simulation ( n );

  d = sort ( d );
  d = [ 0.0; d; 2.0 ];
  cdf = linspace ( 0.0, 1.0, n + 2 );
%
%  Plot a histogram.
%
  clf ( );
  plot ( d, cdf, 'r-', 'linewidth', 3 );
  grid ( 'on' );
  title ( 'CDF for the two fly simulation' );
  xlabel ( '<-- Distance from center -->' );
  ylabel ( '<-- Cumulative Probability -->' );
  filename = 'flies_cdf.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

