function r8vec_variance_update_test ( )

%*****************************************************************************80
%
%% R8VEC_VARIANCE_UPDATE_TEST tests R8VEC_VARIANCE_UPDATE.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    01 December 2017
%
%  Author:
%
%    John Burkardt
%
  n_max = 10;
  a = zeros ( n_max, 1 );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8VEC_VARIANCE_UPDATE_TEST\n' );
  fprintf ( 1, '  R8VEC_VARIANCE_UPDATE updates the variance of a vector\n' );
  fprintf ( 1, '  when one more element is added.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '   N      R           VARIANCE     VARIANCE_UPDATE\n' );
  fprintf ( 1, '\n' );

  mean_n = 0.0;
  variance_n = 0.0;
  seed = 123456789;

  for i = 1 : n_max

    [ r, seed ] = r8_uniform_01 ( seed );
    a(i) = r;
    variance = r8vec_variance ( i, a );
    
    nm1 = i - 1;
    mean_nm1 = mean_n;
    variance_nm1 = variance_n;

    [ n, mean_n, variance_n ] = r8vec_variance_update ( nm1, mean_nm1, ...
      variance_nm1, r );

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

  end

  return
end
