function std = r8vec_std_sample ( n, a )

%*****************************************************************************80
%
%% r8vec_std_sample() returns the sample standard deviation of an R8VEC.
%
%  Discussion:
%
%    The sample 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 - 1 ) )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 December 2017
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of entries in the vector.
%    N should be at least 2.
%
%    real A(N), the vector.
%
%  Output:
%
%    real STD, the sample 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 - 1 ) );

  end

  return
end
