function std = r8vec_std ( n, a )

%*****************************************************************************80
%
%% r8vec_std() returns the standard deviation of an R8VEC.
%
%  Discussion:
%
%    The standard deviation of a vector X of length N is defined as
%
%      mean ( X(1:n) ) = sum ( X(1:n) ) / n
%
%      std ( X(1:n) ) = sqrt ( sum ( ( X(1:n) - mean )^2 ) / n )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 May 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of entries in the vector.
%
%    real A(N), the vector.
%
%  Output:
%
%    real STD, the standard deviation of the vector.
%
  if ( n < 2 )

    std = 0.0;

  else

    mean = sum ( a(1:n) ) / n;

    std = sum ( ( a(1:n) - mean ).^2 );

    std = sqrt ( std / n );

  end

  return
end
