Skip to content

Standard Deviation

Published On:
Aug 2, 2019
Last Updated:
Aug 2, 2019

The standard deviation is a metric which is used to measure the amount of variation in a set of data values.

The standard deviation has the same units as the data.

Equation

σ=(xxˉ)?2n\sigma = \sqrt{\frac{ \sum{(x - \bar{x})?^2}}{n}}

where:
xˉ\bar{x} is the mean (average) of the samples
nn is the number of samples

For example,

4, 8, 7, 3, 12
xˉ=15(4+8+7+3+12)=6.8(xxˉ)=(46.8)2+(86.8)2+(76.8)2+(36.8)2+(126.8)2=\begin{align} \bar{x} &= \frac{1}{5} * (4+8+7+3+12)\\ &= 6.8\\ \\ \sum{(x - \bar{x})} = (4-6.8)^2+(8-6.8)^2+(7-6.8)^2+(3-6.8)^2+(12-6.8)^2\\ = \end{align}

Software

You can calculated the standard deviation of an array in Numpy with np.std():

np.std(my_array)

By default, the array is flattened. However, you can specify an axis on which to calculate the standard deviation.