function fermi_dirac_sample_test ( ) %*****************************************************************************80 % %% FERMI_DIRAC_SAMPLE_TEST tests FERMI_DIRAC_SAMPLE. % % Licensing: % % This code is distributed under the GNU LGPL 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); seed = 123456789; 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), seed ] = fermi_dirac_sample ( u, v, seed ); end z_max = max ( z(1:sample_num) ); z_min = min ( z(1:sample_num) ); mean = r8vec_mean ( sample_num, z ); variance = r8vec_variance ( sample_num, z ); fprintf ( 1, '\n' ); fprintf ( 1, ' SAMPLE_NUM = %d\n', sample_num ); fprintf ( 1, ' Sample mean = %g\n', mean ); 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