function r8vec_mean_update_test ( )

%*****************************************************************************80
%
%% R8VEC_MEAN_UPDATE_TEST tests R8VEC_MEAN_UPDATE.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    30 November 2017
%
%  Author:
%
%    John Burkardt
%
  n_max = 10;
  a = zeros ( n_max, 1 );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8VEC_MEAN_UPDATE_TEST\n' );
  fprintf ( 1, '  R8VEC_MEAN_UPDATE updates the mean of a vector\n' );
  fprintf ( 1, '  when one more element is added.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '   N      R               MEAN         MEAN_UPDATE\n' );
  fprintf ( 1, '\n' );

  seed = 123456789;
  mean_n = 0.0;

  for i = 1 : n_max

    [ r, seed ] = r8_uniform_01 ( seed );
    a(i) = r;
    mean = r8vec_mean ( i, a );
    
    nm1 = i - 1;
    mean_nm1 = mean_n;
    [ n, mean_n ] = r8vec_mean_update ( nm1, mean_nm1, r );

    fprintf ( 1, '  %2d  %14.6g  %14.6g  %14.6g\n', i, r, mean, mean_n );

  end

  return
end