function binomial_sample_test ( )

%*****************************************************************************80
%
%% binomial_sample_test() tests binomial_mean(), binomial_sample(), binomial_variance().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 April 2009
%
%  Author:
%
%    John Burkardt
%
  nsample = 1000;
 
  fprintf ( 1, '\n' );
  fprintf ( 1, 'BINOMIAL_SAMPLE_TEST():\n' );
  fprintf ( 1, '  BINOMIAL_MEAN() computes the Binomial mean;\n' );
  fprintf ( 1, '  BINOMIAL_SAMPLE() samples the Binomial distribution;\n' );
  fprintf ( 1, '  BINOMIAL_VARIANCE() computes the Binomial variance.\n' );

  a = 5;
  b = 0.30;

  check = binomial_check ( a, b );

  if ( ~check );
    fprintf ( 1, '\n' );
    fprintf ( 1, 'BINOMIAL_SAMPLE_TEST - Fatal error!\n' );
    fprintf ( 1, '  The parameters are not legal.\n' );
    return
  end

  pdf_mean = binomial_mean ( a, b );
  pdf_var = binomial_variance ( a, b );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  PDF parameter A = %6d\n', a );
  fprintf ( 1, '  PDF parameter B = %14f\n', b );
  fprintf ( 1, '  PDF mean =        %14f\n', pdf_mean );
  fprintf ( 1, '  PDF variance =    %14f\n', pdf_var );

  x = zeros ( nsample, 1 );
  for i = 1 : nsample
    x(i) = binomial_sample ( a, b );
  end

  xmean = mean ( x );
  xvar = var ( x );
  xmax = max ( x );
  xmin = min ( x );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Sample size =     %6d\n', nsample );
  fprintf ( 1, '  Sample mean =     %14f\n', xmean );
  fprintf ( 1, '  Sample variance = %14f\n', xvar );
  fprintf ( 1, '  Sample maximum =  %6d\n', xmax );
  fprintf ( 1, '  Sample minimum =  %6d\n', xmin );

  return
end
