function hypergeometric_sample_test ( )

%*****************************************************************************80
%
%% hypergeometric_sample_test() tests hypergeometric_sample().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 April 2016
%
%  Author:
%
%    John Burkardt
%
  nsample = 1000;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'HYPERGEOMETRIC_SAMPLE_TEST():\n' );
  fprintf ( 1, '  HYPERGEOMETRIC_MEAN() computes the Hypergeometric mean;\n' );
  fprintf ( 1, '  HYPERGEOMETRIC_SAMPLE() samples the Hypergeometric distribution;\n' );
  fprintf ( 1, '  HYPERGEOMETRIC_VARIANCE() computes the Hypergeometric variance.\n' );

  n = 10;
  m = 7;
  l = 100;

  check = hypergeometric_check ( n, m, l );

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

  hyp_mean = hypergeometric_mean ( n, m, l );
  hyp_var = hypergeometric_variance ( n, m, l );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  PDF parameter N =             %6d\n', n );
  fprintf ( 1, '  PDF parameter M =             %6d\n', m );
  fprintf ( 1, '  PDF parameter L =             %6d\n', l );
  fprintf ( 1, '  PDF mean =                    %14g\n', hyp_mean );
  fprintf ( 1, '  PDF variance =                %14g\n', hyp_var );

  for i = 1 : nsample
    x(i) = hypergeometric_sample ( n, m, l );
  end

  x_mean = mean ( x );
  x_var = var ( x );
  x_max = max ( x );
  x_min = min ( x );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Sample size =     %6d\n', nsample );
  fprintf ( 1, '  Sample mean =     %14g\n', x_mean );
  fprintf ( 1, '  Sample variance = %14g\n', x_var );
  fprintf ( 1, '  Sample maximum =  %6d\n', x_max );
  fprintf ( 1, '  Sample minimum =  %6d\n', x_min );

  return
end
