function cardioid_sample_test ( )

%*****************************************************************************80
%
%% cardioid_sample_test() tests cardioid_mean(), cardioid_sample(), cardioid_variance().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 April 2009
%
%  Author:
%
%    John Burkardt
%
  sample_num = 1000;

  a = 0.0;
  b = 0.25;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'cardioid_sample_test():\n' );
  fprintf ( 1, '  cardioid_mean() computes the Cardioid mean;\n' );
  fprintf ( 1, '  cardioid_sample() samples the Cardioid distribution;\n' );
  fprintf ( 1, '  cardioid_variance() computes the Cardioid variance.\n' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  PDF parameter A = %g\n', a );
  fprintf ( 1, '  PDF parameter B = %g\n', b );

  if ( ~cardioid_check ( a, b ) )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'cardioid_sample_test(): Fatal error!\n' );
    fprintf ( 1, '  The parameters are not legal.\n' );
    return;
  end

  xmean = cardioid_mean ( a, b );
  variance = cardioid_variance ( a, b );

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

  for i = 1 : sample_num
    x(i) = cardioid_sample ( 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 =     %6d\n', sample_num );
  fprintf ( 1, '  Sample mean =     %14f\n', xmean );
  fprintf ( 1, '  Sample variance = %14f\n', variance );
  fprintf ( 1, '  Sample maximum =  %14f\n', xmax );
  fprintf ( 1, '  Sample minimum =  %14f\n', xmin );

  return
end
