function r8_rand_test ( )

%*****************************************************************************80
%
%% R8_RAND_TEST tests R8_RAND.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 May 2016
%
%  Author:
%
%    John Burkardt
%
  i_value = [ 1, 2, 3, 4, 10, 100, 1000 ];
  r_value = [ ...
    0.0004127026, ...
    0.6750836372, ...
    0.1614754200, ...
    0.9086198807, ...
    0.5527787209, ...
    0.3600893021, ...
    0.2176990509 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8_RAND_TEST:\n' );
  fprintf ( 1, '  R8_RAND is a random number generator.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '             I         R8_RAND        Expected\n' );
  fprintf ( 1, '\n' );
%
%  Start the sequence with IX0 = IX1 = 0.
%
  ix0 = 0;
  ix1 = 0;
  s = 0.0;

  k = 1;

  for i = 1 : 1000

    [ r, ix0, ix1 ] = r8_rand ( s, ix0, ix1 );

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

  end
%
%  Restart the sequence with IX0 = IX1 = 0.
%
  ix0 = 0;
  ix1 = 0;
  s = 0.0;

  average = 0.0;
  for i = 1 : 1000000
    [ r, ix0, ix1 ] = r8_rand ( s, ix0, ix1 );
    average = average + r;
  end
  average = average / 1000000.0;
  fprintf ( 1, '\n' );
  fprintf ( 1, '       Average =  %14g  %14g\n', average, 0.5 );
%
%  Restart the sequence with IX0 = IX1 = 0.
%
  ix0 = 0;
  ix1 = 0;
  s = 0.0;

  variance = 0.0;
  for i = 1 : 1000000
    [ r, ix0, ix1 ] = r8_rand ( s, ix0, ix1 );
    variance = variance + ( r - average ) ^ 2;
  end
  variance = variance / 1000000.0;
  fprintf ( 1, '       Variance = %14g  %14g\n', variance, 1.0 / 12.0 );

  return
end