function r8vec_std_updates_test ( )

%*****************************************************************************80
%
%% r8vec_std_updates_test() tests r8vec_std_updates().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 May 2022
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'r8vec_std_updates_test()\n' );
  fprintf ( 1, '  r8vec_std_updates() computes the standard deviation of\n' );
  fprintf ( 1, '    V12 = V1 + V2\n' );
  fprintf ( 1, '  where V1 and V2 are vectors whose length, mean and\n' );
  fprintf ( 1, '  standard deviation are given.\n' );

  n1 = 5;
  v1 = randn ( n1, 1 );
% v1 = [ 1, 2, 3, 4, 5 ];
  mean1 = mean ( v1 );
  std1 = std ( v1 );

  n2 = 7;
  v2 = randn ( n2, 1 );
% v2 = [ 6, 7, 8, 9, 10, 11, 12 ];
  mean2 = mean ( v2 );
  std2 = std ( v2 );

  [ n12, mean12, std12 ] = r8vec_std_updates ( n1, mean1, std1, n2, mean2, std2 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  %d  %g  %g\n', n1, mean1, std1 );
  fprintf ( 1, '  %d  %g  %g\n', n2, mean2, std2 );
  fprintf ( 1, '  %d  %g  %g\n', n12, mean12, std12 );

  v12 = [ v1, v2 ];
  n12 = n1 + n2;
  mean12 = mean ( v12 );
  std12 = std ( v12 );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Recompute directly from V12:\n' );
  fprintf ( 1, '  %d  %g  %g\n', n12, mean12, std12 );

  return
end
