There are two standard deviation formulas, and they differ in exactly one character. This page takes each apart term by term, explains why every operation in them is there, and shows the arithmetic on real numbers. The calculator underneath applies them to your data.
The two formulas
Sample standard deviation — use this when your numbers are a subset drawn from a larger group:
s = √[ Σ(x − x̄)² / (n − 1) ]
Population standard deviation — use this when your numbers are the entire group:
σ = √[ Σ(x − μ)² / N ]
Read either from the inside out: find the mean, measure how far each value sits from it, square those distances, average them, then undo the squaring. The only difference is that the sample version divides by n − 1 where the population version divides by N.
Separate values with commas, spaces, tabs or new lines — paste a column straight from a spreadsheet and it will parse. Decimals and negatives are fine.
The shaded bands are one, two and three standard deviations either side of the mean. 5 of 8 values — 63% — fall inside the innermost band.
Show the working, step by step
Every term, explained
| Term | Name | What it does |
|---|---|---|
| x | Each value | Stands in turn for every individual number in your data. |
| x̄ / μ | Mean | The average — sample mean is written x̄ ("x-bar"), population mean μ ("mu"). |
| x − x̄ | Deviation | How far one value sits from the mean. Negative below it, positive above. |
| (x − x̄)² | Squared deviation | Makes every term positive so they cannot cancel, and penalises far-out values more. |
| Σ | Sum | "Add all of these up." |
| n / N | Count | How many values. Lower case n for a sample, capital N for a population. |
| n − 1 | Degrees of freedom | Bessel's correction — see below. |
| √ | Square root | Returns the answer to the original units after the squaring. |
Why square the deviations at all?
Try averaging the raw deviations on 2, 4, 6. The mean is 4, so the deviations are
−2, 0 and +2, and they sum to zero. That is not a coincidence of this example: the deviations
from the mean sum to zero for every dataset, by the definition of the mean. An
unsquared average of them would report zero spread for all data, which is useless.
Squaring solves that by making every term non-negative. It also has the side effect of weighting a deviation of 10 as a hundred times more significant than a deviation of 1, rather than ten times — which is why a single outlier can move a standard deviation so sharply. Taking the square root at the end undoes the inflation of scale, but not that reweighting.
Why n − 1 for a sample?
A sample's mean is calculated from that sample, so it sits as close to those particular numbers as any single point can. The true population mean is almost always somewhere slightly else, and further from your data on average. Measuring spread around the sample's own too-flattering centre therefore understates the population's real spread every time — the bias is systematic, not random.
Dividing by n − 1 instead of n inflates the result by exactly enough to cancel that bias out. The correction is named for Friedrich Bessel, and its size depends entirely on n:
| n | n / (n − 1) | Effect on the variance |
|---|---|---|
| 3 | 1.500 | 50% larger |
| 5 | 1.250 | 25% larger |
| 10 | 1.111 | 11% larger |
| 30 | 1.034 | 3.4% larger |
| 100 | 1.010 | 1% larger |
| 1000 | 1.001 | 0.1% larger |
For a large sample the choice barely matters. For a small one it matters a great deal, which is exactly when people are most likely to be working by hand and most likely to pick wrong.
A worked example, both ways
Data: 2, 4, 4, 4, 5, 5, 7, 9.
- Sum = 40, count = 8, so the mean is 5.
- Deviations: −3, −1, −1, −1, 0, 0, 2, 4.
- Squared: 9, 1, 1, 1, 0, 0, 4, 16. Their sum, Σ(x − x̄)², is 32.
-
As a population: 32 ÷ 8 = 4, and √4 = σ = 2 exactly.
As a sample: 32 ÷ 7 = 4.5714, and √4.5714 = s = 2.1381.
This is the standard textbook example precisely because the population answer comes out as a whole number. Paste it into the calculator above and toggle the mode to watch only the denominator change.
The shortcut formula, and why not to use it
Older textbooks give a one-pass rearrangement that avoids computing the mean first:
s² = [ Σx² − (Σx)² / n ] / (n − 1)
Algebraically it is identical. Numerically it is not. It subtracts two large, nearly equal
quantities, and in floating-point arithmetic that step throws away most of the significant
digits. On the values 1000000.1, 1000000.2, 1000000.3 — whose true variance is
exactly 0.01 — the shortcut can return zero or even a negative number, which is impossible
for a variance. The formulas at the top of this page, computed with
Welford's algorithm, do not have this failure mode.
Related formulas built from this one
- Variance — everything under the square root:
s² = Σ(x − x̄)² / (n − 1). Calculate it. - Standard error of the mean —
SE = s / √n. Calculate it. - Relative standard deviation —
%RSD = 100 × s / |x̄|. Calculate it. - Z-score —
z = (x − μ) / σ. Calculate it. - Pooled SD —
sp = √[ Σ(nᵢ − 1)sᵢ² / Σ(nᵢ − 1) ]. Calculate it. - Grouped data —
s = √[ Σf(x − x̄)² / (Σf − 1) ]. Calculate it.
Related calculators
-
Standard deviation calculator
Apply the formula to your own numbers and see each step.
-
Symbols and notation
What σ, s, μ, x̄, n and Σ each stand for.
-
Sample vs population
Which denominator to use, and why it matters most for small n.
-
Variance calculator
The same formula without the final square root.
Common questions
What is the standard deviation formula?
For a sample: s = √[ Σ(x − x̄)² / (n − 1) ]. For a population:
σ = √[ Σ(x − μ)² / N ]. The two are identical except for the denominator —
a sample divides by n − 1, a population by N.
Why are the deviations squared?
Because deviations above and below the mean always sum to exactly zero, so averaging them raw would give 0 for every dataset. Squaring makes every term positive so they cannot cancel. It also weights large deviations more heavily than small ones, which is usually what you want from a measure of spread.
Taking absolute values instead would also stop the cancelling — that gives the mean absolute deviation, a real and occasionally preferable statistic. Squaring won out because it is differentiable everywhere and because variances of independent quantities add, which makes the whole of statistical theory tractable.
What is the computational or "shortcut" formula?
s² = [ Σx² − (Σx)²/n ] / (n − 1). It gives the same answer in exact
arithmetic and needs only one pass through the data, which mattered when people worked with
mechanical calculators.
On a computer it is a bad idea. It subtracts two large and nearly equal numbers, which destroys precision — on the data 1000000.1, 1000000.2, 1000000.3 it can return a negative variance. This site uses Welford's algorithm instead.
What does the Σ symbol mean in the formula?
Σ is the Greek capital sigma and means "add up all of these". Σ(x − x̄)²
instructs you to work out (x − x̄)² for every value x in the dataset and total the results.
The full notation guide is here.
Is the standard deviation formula the same as the variance formula?
Almost. The variance is everything under the square root; the standard deviation is the square root of it. So σ = √(σ²), and σ² = σ². The only practical difference is units: variance is in squared units, standard deviation is in the original units.