How to Calculate Standard Deviation: Formula, Steps and Examples
What Is Standard Deviation?
Standard deviation is a measure of how spread out the values in a data set are around their average (the mean). A small standard deviation means most values sit close to the mean. A large standard deviation means values are scattered far from the mean.
Unlike some other spread measures, standard deviation is expressed in the same units as your data. If your data is test scores in points, the standard deviation is also in points. That makes it easy to interpret: a mean score of 70 with a standard deviation of 5 means most scores fall within a few points of 70, while a standard deviation of 20 means scores vary much more widely.
Standard deviation is usually written with the Greek letter sigma (σ) for a population and the letter s for a sample.
Standard Deviation Formula
There are two versions of the standard deviation formula. Which one you use depends on whether your data covers the whole group (a population) or only part of it (a sample).
Population standard deviation (σ):
σ = √[ Σ(x − μ)² / N ]
Sample standard deviation (s):
s = √[ Σ(x − x̄)² / (n − 1) ]
What each symbol means:
- x is each individual value in your data set.
- μ (mu) is the mean of the full population.
- x̄ (x-bar) is the mean of your sample.
- N is the number of values in the population.
- n is the number of values in the sample.
- Σ (sigma) means "add everything up".
The only difference between the two formulas is the denominator: N for a population, and (n − 1) for a sample. Dividing a sample by (n − 1) instead of n is called Bessel's correction. It makes the sample estimate slightly larger, which better reflects the spread of the full group the sample came from.
How to Calculate Standard Deviation Step by Step
Here is how to calculate standard deviation step by step, whichever version you need:
- Step 1: Find the mean. Add up all the values and divide by how many values there are.
- Step 2: Subtract the mean from each value. This gives you the deviation of each value from the average. Some deviations will be negative.
- Step 3: Square each deviation. Squaring removes the negative signs and gives more weight to values far from the mean.
- Step 4: Average the squared deviations. Add them up, then divide by N for a population or by (n − 1) for a sample. This average is called the variance.
- Step 5: Take the square root. The square root of the variance is the standard deviation, back in the original units of your data.
If you would rather not do this by hand, our standard deviation calculator performs all five steps instantly and shows the mean, variance and standard deviation for both sample and population data.
Standard Deviation Example (Population)
Let us work through a standard deviation example with the data set {2, 4, 4, 4, 5, 5, 7, 9}. Treat these 8 values as the full population.
Step 1: Mean. (2 + 4 + 4 + 4 + 5 + 5 + 7 + 9) / 8 = 40 / 8 = 5.
Steps 2 and 3: Deviations and squared deviations.
| Value (x) | x − μ | (x − μ)² |
|---|---|---|
| 2 | −3 | 9 |
| 4 | −1 | 1 |
| 4 | −1 | 1 |
| 4 | −1 | 1 |
| 5 | 0 | 0 |
| 5 | 0 | 0 |
| 7 | 2 | 4 |
| 9 | 4 | 16 |
Step 4: Variance. The squared deviations add up to 9 + 1 + 1 + 1 + 0 + 0 + 4 + 16 = 32. Divide by N = 8: 32 / 8 = 4.
Step 5: Standard deviation. √4 = 2. So the population standard deviation of this data set is 2.
Sample Standard Deviation Example
Now treat the same 8 values, {2, 4, 4, 4, 5, 5, 7, 9}, as a sample taken from a larger group. Steps 1 to 3 are identical: the mean is still 5 and the squared deviations still add up to 32.
The difference comes at Step 4. Instead of dividing by 8, you divide by (n − 1) = 7:
- Sample variance: 32 / 7 ≈ 4.57
- Sample standard deviation: √4.57 ≈ 2.14
The sample standard deviation (about 2.14) is slightly larger than the population standard deviation (2). That is Bessel's correction at work: because a sample usually underestimates the true spread, dividing by (n − 1) nudges the result up.
Sample vs Population Standard Deviation
Choosing between sample vs population standard deviation comes down to one question: do you have data for the entire group, or only part of it?
| Population (σ) | Sample (s) | |
|---|---|---|
| Use it when | You have every value in the group | Your data is only part of a larger group |
| Divide by | N (all values) | n − 1 (values minus one) |
| Mean symbol | μ (mu) | x̄ (x-bar) |
| Example | Heights of all 30 students in one class | Heights of 30 students used to estimate a whole school |
If you are unsure, ask whether there are values in the group that you did not measure. If yes, it is a sample. If you measured everything, it is a population.
Variance vs Standard Deviation
Variance and standard deviation measure the same thing, the spread of data, but in different units. Variance is the average of the squared deviations, so its units are squared (points squared, dollars squared). Standard deviation is the square root of the variance, which brings the units back to match your original data.
In the worked example above, the population variance is 4 and the standard deviation is 2. Because standard deviation is in the original units, it is usually easier to interpret and report. Variance is still useful in formulas and in more advanced statistics, where squared units are expected.
How to Calculate Standard Deviation in Excel
To calculate standard deviation in Excel, put your values in a column or row and use one of the two built-in functions:
- =STDEV.P(range) for a full population. Example: =STDEV.P(A1:A8).
- =STDEV.S(range) for a sample. Example: =STDEV.S(A1:A8).
Replace the range with your own cells. Excel returns the standard deviation in the same units as your data. Older versions of Excel used STDEVP and STDEV for the same two calculations.
What Is Standard Deviation Used For?
Standard deviation is used anywhere you need to describe how consistent or variable a set of numbers is:
- Test scores and grades: to see whether scores are tightly grouped or widely spread around the class average.
- Quality control: to check whether manufactured parts stay close to their target size or drift over time.
- Finance: to describe how much an investment's returns vary, which is one common way of talking about volatility and risk.
- Research and experiments: to report how much repeated measurements differ from each other.
In each case the standard deviation is read alongside the mean: together they give a quick picture of both the typical value and how much values vary around it. If your data involves probabilities and expected outcomes as well, our probability calculator can help with that side of the analysis.
Frequently Asked Questions About Standard Deviation
How do you calculate standard deviation?
To calculate standard deviation, find the mean of your data, subtract the mean from each value, square each difference, average the squared differences (divide by n for a population or n minus 1 for a sample), then take the square root. The result is in the same units as your data.
What is the standard deviation formula?
The population standard deviation formula is the square root of the sum of (x minus mu) squared, divided by N. The sample formula is the square root of the sum of (x minus x-bar) squared, divided by (n minus 1). Here mu is the population mean, x-bar is the sample mean, N is the population size, and n is the sample size.
What is the difference between sample and population standard deviation?
Population standard deviation describes every value in the full group and divides by N. Sample standard deviation estimates the spread of a larger group from a smaller set of values and divides by (n minus 1), which corrects the estimate upward slightly. Use the population version when you have all the data, and the sample version when your data is only part of the group.
What is a good standard deviation?
There is no universal good or bad standard deviation. It only has meaning compared with the mean and the context of the data. A small standard deviation relative to the mean means values are tightly grouped, while a large one means values are widely spread. Whether that spread is good depends on what you are measuring.
How do you calculate standard deviation in Excel?
In Excel, use =STDEV.P(range) when your data is the full population and =STDEV.S(range) when your data is a sample. Replace range with your cells, for example =STDEV.S(A1:A8). Excel returns the standard deviation in the same units as your data.