function normal_truncated_a_sample_test ( ) %*****************************************************************************80 % %% NORMAL_TRUNCATED_A_SAMPLE_TEST tests NORMAL_TRUNCATED_A_SAMPLE. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 11 April 2016 % % Author: % % John Burkardt % sample_num = 1000; seed = 123456789; a = 50.0; mu = 100.0; s = 25.0; fprintf ( 1, '\n' ); fprintf ( 1, 'NORMAL_TRUNCATED_A_SAMPLE_TEST\n' ); fprintf ( 1, ' NORMAL_TRUNCATED_A_MEAN computes the Normal Truncated A mean;\n' ); fprintf ( 1, ' NORMAL_TRUNCATED_A_SAMPLE samples the Normal Truncated A distribution;\n' ); fprintf ( 1, ' NORMAL_TRUNCATED_A_VARIANCE computes the Normal Truncated A variance.\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' The "parent" normal distribution has\n' ); fprintf ( 1, ' mean = %g\n', mu ); fprintf ( 1, ' standard deviation = %g\n', s ); fprintf ( 1, ' The parent distribution is truncated to\n' ); fprintf ( 1, ' the interval [%g,+oo]\n', a ); mean = normal_truncated_a_mean ( mu, s, a ); variance = normal_truncated_a_variance ( mu, s, a ); fprintf ( 1, '\n' ); fprintf ( 1, ' PDF mean = %g\n', mean ); fprintf ( 1, ' PDF variance = %g\n', variance ); for i = 1 : sample_num [ x(i), seed ] = normal_truncated_a_sample ( mu, s, a, seed ); end mean = r8vec_mean ( sample_num, x ); variance = r8vec_variance ( sample_num, x ); xmax = r8vec_max ( sample_num, x ); xmin = r8vec_min ( sample_num, x ); fprintf ( 1, '\n' ); fprintf ( 1, ' Sample size = %d\n', sample_num ); fprintf ( 1, ' Sample mean = %g\n', mean ); fprintf ( 1, ' Sample variance = %g\n', variance ); fprintf ( 1, ' Sample maximum = %g\n', xmax ); fprintf ( 1, ' Sample minimum = %g\n', xmin ); return end