Home / Articles / How to calculate standard deviation

How to Calculate Standard Deviation

Standard deviation tells you how spread out the values in a data set are around the average, and it is one of the most useful numbers in statistics.

Chris Terry
By Chris Terry, Founder & Editor
Updated June 17, 2026

Crunch your numbers

Paste your data set and get mean, variance, and standard deviation in seconds.

Standard deviation is the square root of the average squared distance each data point sits from the mean. For a sample, divide by n minus 1; for a whole population, divide by n. A small SD means values cluster tightly; a large SD means they are spread wide.

The formula

For a sample (the common case when you collected data from a subset of a population):

s = sqrt( sum((x - x_bar)^2) / (n - 1) )

Where x_bar is the sample mean and n is the number of data points. Dividing by n minus 1 (Bessel's correction) gives an unbiased estimate of the population spread.

For a population (when you have every value, not just a sample):

sigma = sqrt( sum((x - mu)^2) / n )

Step-by-step worked example

Data set: 4, 7, 13, 16

StepCalculationResult
1. Find the mean(4 + 7 + 13 + 16) / 410
2. Subtract mean, square each(4-10)^2, (7-10)^2, (13-10)^2, (16-10)^236, 9, 9, 36
3. Sum of squares36 + 9 + 9 + 3690
4. Divide by n-1 (sample)90 / 330 (variance)
5. Take square rootsqrt(30)5.48 (SD)

The standard deviation is 5.48. Each value is, on average, about 5.5 units from the mean of 10.

Population vs sample: which do you use?

Use the sample formula (divide by n minus 1) whenever your data is a sample drawn from a larger population, which is the most common case in research, surveys, and experiments. Use the population formula (divide by n) only when you have every single value in the group you care about (for example, the exact test scores of every student in one specific class, with no intention to generalize).

What does the number mean?

Standard deviation is in the same units as your original data. An SD of 5.48 on a data set measured in kilograms means values typically sit within about 5.48 kg of the mean. A larger SD signals more variability; a smaller SD signals less. In a normal distribution, roughly 68% of values fall within one SD of the mean, and about 95% fall within two SDs. See z-scores to put any single value in context relative to the SD.

Common mistakes

The two most frequent errors are using the population formula on sample data (which underestimates variability) and forgetting to take the square root at the end (which gives the variance, not the SD). If your calculator or spreadsheet gives you a choice between STDEV and STDEVP (or SD and sigma), pick STDEV for sample data.

Crunch your numbers

Paste your data set and get mean, variance, and standard deviation in seconds.

Related reading

Good to know

FAQs

What is the standard deviation of 5 5 5 9 9 9 10 10 10?

Mean = (5+5+5+9+9+9+10+10+10)/9 = 72/9 = 8. Squared deviations: (5-8)^2 = 9, repeated three times; (9-8)^2 = 1, three times; (10-8)^2 = 4, three times. Sum = 27 + 3 + 12 = 42. Sample variance = 42/8 = 5.25. Sample SD = sqrt(5.25) = approximately 2.29.

What is the fastest way to calculate standard deviation?

The fastest way is to paste your values into a calculator tool. In a spreadsheet, =STDEV(range) gives the sample SD instantly. For hand calculations, the shortcut formula s = sqrt( (sum of x^2 - n*x_bar^2) / (n-1) ) avoids computing each deviation separately.

Why is the formula for standard deviation?

The formula measures spread by squaring the distance from the mean (so negatives do not cancel positives), averaging those squared distances, then square-rooting back to the original units. Squaring punishes outliers more heavily than a simple average distance would, which makes SD sensitive to extreme values.

What is the formula for calculating the standard deviation?

Sample SD: s = sqrt( sum((x - x_bar)^2) / (n - 1) ). Population SD: sigma = sqrt( sum((x - mu)^2) / n ). In both cases x_bar or mu is the mean, n is the count, and the sum runs over every data point.