function normal_truncated_ab_sample_test ( )

%*****************************************************************************80
%
%% normal_truncated_ab_sample_test() tests normal_truncated_ab_sample().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 April 2016
%
%  Author:
%
%    John Burkardt
%
  sample_num = 1000;

  a = 50.0;
  b = 150.0;
  mu = 100.0;
  s = 25.0;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'NORMAL_TRUNCATED_AB_SAMPLE_TEST():\n' );
  fprintf ( 1, '  NORMAL_TRUNCATED_AB_MEAN() computes the Normal Truncated AB mean;\n' );
  fprintf ( 1, '  NORMAL_TRUNCATED_AB_SAMPLE() samples the Normal Truncated AB distribution;\n' );
  fprintf ( 1, '  NORMAL_TRUNCATED_AB_VARIANCE() computes the Normal Truncated AB 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,%g]\n', a, b );

  xmean = normal_truncated_ab_mean ( mu, s, a, b );

  variance = normal_truncated_ab_variance ( mu, s, a, b );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  PDF mean      =               %g\n', xmean );
  fprintf ( 1, '  PDF variance =                %g\n', variance );

  for i = 1 : sample_num
    x(i) = normal_truncated_ab_sample ( mu, s, a, b );
  end

  xmean = mean ( x );
  variance = r8vec_variance ( sample_num, x );
  xmax = max ( x );
  xmin = min ( x );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Sample size =     %d\n', sample_num );
  fprintf ( 1, '  Sample mean =     %g\n', xmean );
  fprintf ( 1, '  Sample variance = %g\n', variance );
  fprintf ( 1, '  Sample maximum =  %g\n', xmax );
  fprintf ( 1, '  Sample minimum =  %g\n', xmin );

  return
end
