function r8vec_std_update_test ( )

%*****************************************************************************80
%
%% R8VEC_STD_UPDATE_TEST tests R8VEC_STD_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_STD_UPDATE_TEST\n' );
  fprintf ( 1, '  R8VEC_STD_UPDATE updates the standard deviation of a vector\n' );
  fprintf ( 1, '  when one more element is added.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '   N      R                STD         STD_UPDATE\n' );
  fprintf ( 1, '\n' );

  mean_n = 0.0;
  std_n = 0.0;
  seed = 123456789;

  for i = 1 : n_max

    [ r, seed ] = r8_uniform_01 ( seed );
    a(i) = r;
    std = r8vec_std ( i, a );
    
    nm1 = i - 1;
    mean_nm1 = mean_n;
    std_nm1 = std_n;

    [ n, mean_n, std_n ] = r8vec_std_update ( nm1, mean_nm1, ...
      std_nm1, r );

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

  end

  return
end
