function r8_ren_test ( )

%*****************************************************************************80
%
%% R8_REN_TEST tests R8_REN.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    23 April 2016
%
%  Author:
%
%    John Burkardt
%
  i_value = [ 1, 2, 3, 4, 10, 100, 1000 ];
  r_value = [ ...
    0.470393E+00, ...
    0.799066E+00, ...
    0.883261E+00, ...
    0.407667E+00, ...
    0.955566E+00, ...
    0.173576E+00, ...
    0.121733E-01 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8_REN_TEST:\n' );
  fprintf ( 1, '  R8_REN is a random number generator.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '             I         R8_REN         Expected\n' );
  fprintf ( 1, '\n' );

  seed = 100001;
  k = 1;
  for i = 1 : 1000

    [ r, seed ] = r8_ren ( seed );

    if ( i == i_value(k) )
      fprintf ( 1, '  %14d  %14.6g  %14.6g\n', i, r, r_value(k) );
      k = k + 1;
    end

  end

  seed = 100001;
  average = 0.0;
  for i = 1 : 1000000
    [ r, seed ] = r8_ren ( seed );
    average = average + r;
  end
  average = average / 1000000.0;
  fprintf ( 1, '\n' );
  fprintf ( 1, '       Average =  %14.6g  %14.6g\n', average, 0.5 );

  seed = 100001;
  variance = 0.0;
  for i = 1 : 1000000
    [ r, seed ] = r8_ren ( seed );
    variance = variance + ( r - average ) ^ 2;
  end
  variance = variance / 1000000.0;
  fprintf ( 1, '       Variance = %14.6g  %14.6g\n', variance, 1.0 / 12.0 );

  return
end