function r8_random_test ( )

%*****************************************************************************80
%
%% R8_RANDOM_TEST tests R8_RANDOM.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    09 May 2016
%
%  Author:
%
%    John Burkardt
%
  n = 32;
  t = zeros ( n + 1, 1 );
  i_value = [ 1, 2, 3, 4, 10, 100, 1000 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8_RANDOM_TEST:\n' );
  fprintf ( 1, '  R8_RANDOM is a random number generator.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '             I         R8_RANDOM\n' );
  fprintf ( 1, '\n' );
%
%  Start the sequence with IX0 = IX1 = 0.
%
  ix0 = 0;
  ix1 = 0;
  [ t, ix0, ix1 ] = r8_random_init ( n, t, ix0, ix1 );

  k = 1;

  for i = 1 : 1000

    [ r, t, ix0, ix1 ] = r8_random ( n, t, ix0, ix1 );

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

  end
%
%  Restart the sequence with IX0 = IX1 = 0.
%
  ix0 = 0;
  ix1 = 0;
  [ t, ix0, ix1 ] = r8_random_init ( n, t, ix0, ix1 );

  average = 0.0;
  for i = 1 : 1000000
    [ r, t, ix0, ix1 ] = r8_random ( n, t, 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;
  [ t, ix0, ix1 ] = r8_random_init ( n, t, ix0, ix1 );

  variance = 0.0;
  for i = 1 : 1000000
    [ r, t, ix0, ix1 ] = r8_random ( n, t, 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
