function r8vec_std_sample_update_test ( )

%*****************************************************************************80
%
%% r8vec_std_sample_update_test() tests r8vec_std_sample_update().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 May 2021
%
%  Author:
%
%    John Burkardt
%
  n_max = 10;
  a = zeros ( n_max, 1 );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'r8vec_std_sample_update_test():\n' );
  fprintf ( 1, '  r8vec_std_sample_update() updates the sample standard deviation\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;

  for i = 1 : n_max

    r = rand ( 1, 1 );
    a(i) = r;
    std = r8vec_std_sample ( i, a );
    
    nm1 = i - 1;
    mean_nm1 = mean_n;
    std_nm1 = std_n;

    [ n, mean_n, std_n ] = r8vec_std_sample_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
