function benford_cdf_test ( )

%*****************************************************************************80
%
%% benford_cdf_test() tests benford_cdf(), benford_cdf_inv(), benford_pdf().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 November 2022
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'benford_cdf_test():\n' );
  fprintf ( 1, '  benford_cdf() evaluates the Benford CDF.\n' );
  fprintf ( 1, '  benford_cdf_inv() inverts the Benford CDF.\n' );
  fprintf ( 1, '  benford_pdf() evaluates the Benford PDF.\n' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '       N          CDF(N)          CDF(N) by summing\n' );
  fprintf ( 1, '\n' );

  cdf2 = 0.0;
  for n = 1 : 9
    cdf = benford_cdf ( n );
    pdf = benford_pdf ( n );
    cdf2 = cdf2 + pdf;
    fprintf ( 1, '  %6d  %14g  %14g\n', n, cdf, cdf2 );
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '       N          CDF(N)          CDF(N) by summing\n' );
  fprintf ( 1, '\n' );

  cdf2 = 0.0;
  for n = 10 : 99
    cdf = benford_cdf ( n );
    pdf = benford_pdf ( n );
    cdf2 = cdf2 + pdf;
    fprintf ( 1, '  %6d  %14g  %14g\n', n, cdf, cdf2 );
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '       X            PDF           CDF            CDF_INV\n' );
  fprintf ( 1, '\n' );

  for i = 1 : 10

    x = benford_sample ( );

    pdf = benford_pdf ( x );

    cdf = benford_cdf ( x );

    x2 = benford_cdf_inv ( cdf );

    fprintf ( 1, ' %14g  %14g  %14g  %14g\n', x, pdf, cdf, x2 );

  end
  return
end
