function arcsin_sample_test ( )

%*****************************************************************************80
%
%% arcsin_sample_test() tests arcsin_sample().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 April 2009
%
%  Author:
%
%    John Burkardt
%
  nsample = 1000;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'ARCSIN_SAMPLE_TEST():\n' );
  fprintf ( 1, '  ARCSIN_MEAN() computes the Arcsin mean;\n' );
  fprintf ( 1, '  ARCSIN_SAMPLE() samples the Arcsin distribution;\n' );
  fprintf ( 1, '  ARCSIN_VARIANCE() computes the Arcsin variance.\n' );

  for i = 1 : 2

    if ( i == 1 );
      a = 1.0;
    elseif ( i == 2 );
      a = 16.0;
    end

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

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

    xmean = arcsin_mean ( a );
    variance = arcsin_variance ( a );

    fprintf ( 1, '  PDF mean =        %14f\n', xmean );
    fprintf ( 1, '  PDF variance =    %14f\n', variance );
  
    for j = 1 : nsample
      x(j) = arcsin_sample ( a );
    end

    xmean = mean ( x );
    variance = r8vec_variance ( nsample, 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', variance );
    fprintf ( 1, '  Sample maximum =  %14f\n', xmax );
    fprintf ( 1, '  Sample minimum =  %14f\n', xmin );

  end

  return
end
