function fermi_dirac_sample_test ( )

%*****************************************************************************80
%
%% fermi_dirac_sample_test() tests fermi_dirac_sample().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 April 2016
%
%  Author:
%
%    John Burkardt
%
  sample_num = 10000;
  test_num = 7;

  u_test = [ 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 1.0 ];
  v_test = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.25 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, 'FERMI_DIRAC_SAMPLE_TEST():\n' );
  fprintf ( 1, '  FERMI_DIRAC_SAMPLE() samples the Fermi Dirac distribution.\n' );

  for test = 1 : test_num

    u = u_test(test);
    v = v_test(test);

    fprintf ( 1, '\n' );
    fprintf ( 1, '  U =          %g\n', u );
    fprintf ( 1, '  V =          %g\n', v );

    z = zeros ( sample_num, 1 );
    for i = 1 : sample_num
      z(i) = fermi_dirac_sample ( u, v );
    end

    xmean = mean ( z );
    variance = r8vec_variance ( sample_num, z );
    z_max = max ( z );
    z_min = min ( z );

    fprintf ( 1, '\n' );
    fprintf ( 1, '  SAMPLE_NUM =      %d\n', sample_num );
    fprintf ( 1, '  Sample mean =     %g\n', xmean );
    fprintf ( 1, '  Sample variance = %g\n', variance );
    fprintf ( 1, '  Maximum value =   %g\n', z_max );
    fprintf ( 1, '  Minimum value =   %g\n', z_min );

  end

  return
end
