Calculates the standard deviation of a given population.

View versions (1)

Interface

#include <codecogs/statistics/moments/standard_deviation.h>

using namespace Statistics::Moments;

The standard deviation \sigma is defined by the square root of the bias-corrected variance

\sigma = \sqrt{ \frac {1}{N-1} \sum_{i=1}^N (x_i - \overline{x})^2 }
(1)

Physical scientists often use the term root-mean-square as a synonym for standard deviation when they refer to the square root of the mean squared deviation of a quantity from a given baseline. The standard deviation arises naturally in mathematical statistics through its definition in terms of the second central moment. However, a more natural but much less frequently encountered measure of average deviation from the mean that is used in descriptive statistics is the so-called mean deviation.

If the value of the boolean argument total is true, then the standard deviation is computed using the following formula:

\sigma = \sqrt{ \frac {1}{N} \sum_{i=1}^N (x_i - \overline{x})^2 }
(2)

References

MathWorld, http:mathworld.wolfram.com/StandardDeviation.html

Example 1

#include <codecogs/statistics/moments/standard_deviation.h>
#include <iostream>
int main()
{
  double x[5] = {2.5 , 6.2 , 8.0 , 9.6 , 3.8};
  double dev = Stats::Moments::stdev<double>(5, x);
  std::cout << "The population standard deviation is: " << dev << std::endl;
  return 0;
}

Output:

The population standard deviation is: 2.9192

Parameters

n
the size of the population
data
the actual population data given as an array
total
Default value = false

Returns

the standard deviation mean of a given population
GPL Licence — free for non commercial use. See Licence details.