# Standard deviation

In probability and statistics, the standard deviation is the most commonly used measure of statistical dispersion. Simply put, it measures how spread out the values in a data set are.

The importance of the standard deviation arises from Chebyshev's theorem, which asserts that in any data set, nearly all of the values will be close to the mean value, where the meaning of "close to" is specified by the standard deviation.

The standard deviation is defined as the square root of the variance. This means it is the root mean square (RMS) deviation from the average. It is defined this way in order to give us a measure of dispersion that is (1) a non-negative number, and (2) has the same units as the data. For example, if the data are distance measurements in meters, the standard deviation will also be measured in meters.

A distinction is made between the standard deviation σ (sigma) of a whole population or of a random variable, and the standard deviation s of a subset-population sample. The formulae are given below.

The term standard deviation was introduced to statistics by Karl Pearson (On the dissection of asymmetrical frequency curves, 1894).

## Basics

If you are not a mathematician, but still want to try to understand the calculations, look at this link, where it is all explained with an Excel spreadsheet. http://www.beyondtechnology.com/tips016.shtml (Otherwise, read on below.)

Let $X=(X_{1},X_{2},\dots ,X_{n})$ be a vector of real numbers.

$X\in {\mathbb {R}}^{n},\qquad n\in {\mathbb {N}}.$

We write

$X\approx \mu \pm \sigma$

meaning that $\ X$ is estimated by the mean value $\ \mu$, and the standard deviation is $\ \sigma .$

$\ \mu$ is a real number, and $\ \sigma$ is a signless real number, meaning that $\ \sigma$ and $\ -\sigma$ are considered equivalent.

$\mu \in {\mathbb {R}},\qquad \sigma \in {\mathbb {R}}/\lbrace {+1,-1\rbrace }.$

The case $n=2$ is per definition

$X\approx {\frac {X_{1}+X_{2}}{2}}\pm {\frac {|X_{1}-X_{2}|}{2}}.$

Note the special case $\ X_{1}=X_{2}$

$X\approx X_{1}\pm 0.$

The case

$(+1,-1)\approx 0\pm 1=\pm 1$

justifies the use of the sign $\ \pm .$

A few rules apply. If $\ X=(X_{1},X_{2})\approx \mu \pm \sigma$then

1. Symmetry: $\ (X_{2},X_{1})\approx \mu \pm \sigma .$
2. Addition: $\ a+X=(a+X_{1},a+X_{2})\approx (a+\mu )\pm \sigma .$
3. Multiplication: $\ aX=(aX_{1},aX_{2})\approx a\mu \pm a\sigma .$

The addition rule looks like a rule of associativity,

$\ a+(\mu \pm \sigma )=(a+\mu )\pm \sigma ,$

and the multiplication rule looks like a rule of distributivity,

$\ a(\mu \pm \sigma )=a\mu \pm a\sigma .$

So

$X\approx \mu \pm \sigma =\mu +\sigma (\pm 1)$

Consider the power sums:

$\ s_{j}=\sum _{k}{X_{k}^{j}},\quad j\in {\mathbb N}_{0}$

(Note that $\ s_{0}=n.\qquad s_{1}=X_{1}+\dots +X_{n}.\qquad s_{2}=X_{1}^{2}+\dots +X_{n}^{2}.$)

The power sums $\ s_{j}$ are symmetric functions of the vector $\ X$, and the symmetric functions $\ \mu$ and $\ \sigma$ are written in terms of these like this:

$\ \mu =s_{1}s_{0}^{{-1}}$
$\ \sigma =(s_{0}s_{2}-s_{1}^{2})^{{1/2}}s_{0}^{{-1}}$

or

$\ X\approx {\frac {s_{1}\pm {\sqrt {s_{0}s_{2}-s_{1}^{2}}}}{s_{0}}}.$

This formula is readily checked for the special case $n=2$, and it generalizes the definition to $n\in {\mathbb {N}}$ preserving the rules.

The case $n=1$ is

$X\approx X_{1}\pm 0.$

Examples:

$(1)\approx 1\pm 0.$
$(1,1)\approx 1\pm 0.$
$(1,-1)\approx 0\pm 1.$
$(1,1,1)\approx 1\pm 0.$
$(1,1,-1,-1)\approx 0\pm 1.$

When the standard deviation is zero, the sign $\ \pm 0$ may be omitted, and the sign $\approx$ is replaced by $\ =.$

## Interpretation and application

The standard deviation is a measure of the degree of dispersion of the data from the mean value. Stated another way, the standard deviation is simply the "average" or "expected" variation around an average (i.e., square all individual deviations around the average, add these up, divide by 'N', then take the square root. You then have the 'root' of the mean squared deviation [RMS]: in a very simple sense the "average" or expected variation around the average).

A large standard deviation indicates that the data points are far from the mean and a small standard deviation indicates that they are clustered closely around the mean.

For example, the three samples (0, 0, 14, 14), (0, 6, 8, 14), and (6, 6, 8, 8) each has an average of 7. Their standard deviations are 7, 5 and 1, respectively. The third set has a much smaller standard deviation than the other two because its values are all close to 7.

Standard deviation may be thought of as a measure of uncertainty. In physical science for example, the reported standard deviation of a group of repeated measurements should give the precision of those measurements. When deciding whether measurements agree with a theoretical prediction, the standard deviation of those measurements is of crucial importance: if the mean of the measurements is too far away from the prediction (with the distance measured in standard deviations), then we consider the measurements as contradicting the prediction. This makes sense since they fall outside the range of values that could reasonably be expected to occur if the prediction were correct and the standard deviation appropriately quantified. See prediction interval.

## Definition and shortcut calculation of standard deviation

Suppose we are given a population x1, ..., xN of values (which are real numbers). The arithmetic mean of this population is defined as

$\overline {x}={\frac {1}{N}}\sum _{{i=1}}^{N}x_{i}={\frac {x_{1}+x_{2}+\dots +x_{n}}{N}}$.

(see summation notation) and the standard deviation of this population is defined as

$\sigma ={\sqrt {{\frac {1}{N}}\sum _{{i=1}}^{N}(x_{i}-\overline {x})^{2}}}$.

The standard deviation of a random variable X is defined as

$\sigma ={\sqrt {\operatorname {E}((X-\operatorname {E}(X))^{2})}}={\sqrt {\operatorname {E}(X^{2})-(\operatorname {E}(X))^{2}}}$.

Note that not all random variables have a standard deviation, since these expected values need not exist. If the random variable X takes on the values x1,...,xN with equal probability, then its standard deviation can be computed with the formula given earlier.

Given only a sample of values x1,...,xN from some larger population, many authors define the sample standard deviation by

$s={\sqrt {{\frac {1}{N-1}}\sum _{{i=1}}^{N}(x_{i}-\overline {x})^{2}}}.$

The reason for this definition is that s2 is an unbiased estimator for the variance σ2 of the underlying population. (The derivation of this equation assumes only that the samples are uncorrelated and makes no assumption as to their distribution.) However, s is not an unbiased estimator for the standard deviation σ; it tends to underestimate the population standard deviation. Although an unbiased estimator for "s" is known when the random variable is normally distributed, the formula is complicated and amounts to a minor correction. Moreover, unbiasedness, in this sense of the word, is not always desirable; see bias (statistics). Some have even argued that even the difference between N and N − 1 in the denominator is overly complex and insignificant. Without that term, what is left is the simpler expression

$s={\sqrt {{\frac {1}{N}}\sum _{{i=1}}^{N}(x_{i}-\overline {x})^{2}}}.$

This form has the desirable property of being the maximum-likelihood estimate when the population (or the random variable X) is normally distributed.

## Examples

We will show how to calculate the standard deviation of a population. Our example will use the ages of four young children: { 5, 6, 8, 9 }.

Step 1. Calculate the mean/average $\overline {x}$.

$\overline {x}={\frac {1}{N}}\sum _{{i=1}}^{N}x_{i}$.

We have N = 4 because there are four data points:

$x_{1}=5\,\!$
$x_{2}=6\,\!$
$x_{3}=8\,\!$
$x_{4}=9\,\!$
$\overline {x}={\frac {1}{4}}\sum _{{i=1}}^{4}x_{i}$       Replacing N with 4
$\overline {x}={\frac {1}{4}}\left(x_{1}+x_{2}+x_{3}+x_{4}\right)$
$\overline {x}={\frac {1}{4}}\left(5+6+8+9\right)$
$\overline {x}=7$   This is the mean.

Step 2. Calculate the standard deviation $\sigma \,\!$

$\sigma ={\sqrt {{\frac {1}{N}}\sum _{{i=1}}^{N}(x_{i}-\overline {x})^{2}}}$
$\sigma ={\sqrt {{\frac {1}{4}}\sum _{{i=1}}^{4}(x_{i}-\overline {x})^{2}}}$       Replacing N with 4
$\sigma ={\sqrt {{\frac {1}{4}}\sum _{{i=1}}^{4}(x_{i}-7)^{2}}}$       Replacing $\overline {x}$ with 7
$\sigma ={\sqrt {{\frac {1}{4}}\left[(x_{1}-7)^{2}+(x_{2}-7)^{2}+(x_{3}-7)^{2}+(x_{4}-7)^{2}\right]}}$
$\sigma ={\sqrt {{\frac {1}{4}}\left[(5-7)^{2}+(6-7)^{2}+(8-7)^{2}+(9-7)^{2}\right]}}$
$\sigma ={\sqrt {{\frac {1}{4}}\left((-2)^{2}+(-1)^{2}+1^{2}+2^{2}\right)}}$
$\sigma ={\sqrt {{\frac {1}{4}}\left(4+1+1+4\right)}}$
$\sigma ={\sqrt {{\frac {10}{4}}}}$
$\sigma =1.5811\,\!$   This is the standard deviation.

Were this set a sample drawn from a larger population of children, and the question at hand was the standard deviation of the population, convention would replace the N (or 4) here with N−1 (or 3).

## Rules for normally distributed data

File:Standard deviation diagram.png
Dark blue is less than one standard deviation from the mean. For the normal distribution, this accounts for 68.26% of the set. For the normal distribution, two standard deviations from the mean (blue and brown) account for 95.46%. For the normal distribution, three standard deviations (blue, brown and green) account for 99.73%.

In practice, one often assumes that the data are from an approximately normally distributed population. If that assumption is justified, then about 68.26% of the values are at within 1 standard deviation away from the mean, about 95.46% of the values are within two standard deviations and about 99.73% lie within 3 standard deviations. This is known as the "68-95-99.7 rule". As a word of caution, typically this assumption becomes less accurate in the tails.

## Relationship between standard deviation and mean

The mean and the standard deviation of a set of data are usually reported together. In a certain sense, the standard deviation is a "natural" measure of statistical dispersion if the center of the data is measured about the mean. The precise statement is the following: suppose x1, ..., xn are real numbers and define the function

$\sigma (r)={\sqrt {{\frac {1}{N}}\sum _{{i=1}}^{N}(x_{i}-r)^{2}}}$

Using calculus, it is not difficult to show that σ(r) has a unique minimum at the mean

$r=\overline {x}\,$

(this can also be done with fairly simple algebra alone, since, as a function of r, it is a quadratic polynomial).

The coefficient of variation of a sample is the ratio of the standard deviation to the mean. It is a dimensionless number that can be used to compare the amount of variance between populations with different means.

## Rapid calculation methods

A slightly faster way to compute the sample standard deviation is given by the formula (but this can exacerbate round-off error)

$s={\sqrt {{\frac {\sum _{{i=1}}^{N}{{x_{i}}^{2}}-N\left(\overline {x}\right)^{2}}{(N-1)}}\ }}.$

Or from running sums:

$s={\sqrt {{\frac {N\sum _{{i=1}}^{N}{{x_{i}}^{2}}-\left(\sum _{{i=1}}^{N}{x_{i}}\right)^{2}}{N(N-1)}}}}.$

## Geometric interpretation

To gain some geometric insights, we will start with a population of three values, x1, x2, x3. This defines a point P = (x1, x2, x3) in R3. Consider the line L = {(r, r, r) : r in R}. This is the "main diagonal" going through the origin. If our three given values were all equal, then the standard deviation would be zero and P would lie on L. So it is not unreasonable to assume that the standard deviation is related to the distance of P to L. And that is indeed the case. Moving orthogonally from P to the line L, one hits the point

$R=(\overline {x},\overline {x},\overline {x})$

whose coordinates are the mean of the values we started out with. A little algebra shows that the distance between P and R (which is the same as the distance between P and the line L) is given by σ√3. An analogous formula (with 3 replaced by N) is also valid for a population of N values; we then have to work in RN.

## Common predefined functions

Many databases, spreadsheets and programming languages provide built-in functions to calculate various statistical values for you. The function for computing standard deviation based on data from an entire population is usually named something like STDDEV_POP, STDDEVP or STDEVP. If your data is only subset (a sample) use a function named something like STDDEV_SAMP, STDDEV or STDEV instead. Before using a function named STD check its documentation, as it might work either way.