Standard Deviation Formula: Step-by-Step Guide
In this article
To calculate the basic standard deviation of a dataset, first find the mean, then subtract the mean from each value and square the result, average those squared differences, and finally take the square root. That gives you the population standard deviation; for a sample, divide by n−1 instead of n before taking the square root. The steps below walk through the whole process with a small worked example so you can follow along with a calculator, spreadsheet, or by hand.
What You'll Need
- A set of numerical data (at least two values; more is better for a meaningful result).
- A calculator with a square-root button, or a spreadsheet such as Excel, Google Sheets, or LibreOffice Calc.
- Paper and pencil if you want to track intermediate results.
- Knowledge of whether your data is a sample or the entire population — this decides whether you divide by n or n−1.
Step-by-Step
- Write down your data values. List every number in the dataset. For this example, use the values 4, 8, 6, 5, 3. Count how many values you have: n = 5.
- Find the mean (average). Add all values together, then divide by n. Sum = 4 + 8 + 6 + 5 + 3 = 26. Mean = 26 ÷ 5 = 5.2.
- Subtract the mean from each value. These are the deviations. For each number: 4 − 5.2 = −1.2; 8 − 5.2 = 2.8; 6 − 5.2 = 0.8; 5 − 5.2 = −0.2; 3 − 5.2 = −2.2.
- Square each deviation. Squaring removes the negative signs and gives more weight to larger differences. Results: (−1.2)² = 1.44; (2.8)² = 7.84; (0.8)² = 0.64; (−0.2)² = 0.04; (−2.2)² = 4.84.
- Add the squared deviations. Sum of squares = 1.44 + 7.84 + 0.64 + 0.04 + 4.84 = 14.8. This is often called the sum of squared deviations.
- Divide by n or n−1. If your data is the entire population, divide by n = 5: variance = 14.8 ÷ 5 = 2.96. If it is a sample drawn from a larger group, divide by n−1 = 4: sample variance = 14.8 ÷ 4 = 3.7. The n−1 version is called Bessel's correction and gives an unbiased estimate of the population variance.
- Take the square root. Population standard deviation = √2.96 ≈ 1.72. Sample standard deviation = √3.7 ≈ 1.92. Round to a sensible number of decimal places, usually one or two more than your original data.
- Check your work with a spreadsheet. In Excel or Google Sheets, use
=STDEV.P(range)for the population standard deviation or=STDEV.S(range)for the sample version. Enter your values in a column, then point the formula at that range. The result should match your manual calculation (allowing for rounding).
Common Mistakes
- Dividing by n when you have a sample. If your data represents a subset of a larger group, use n−1. Using n underestimates the true variability.
- Forgetting to square the deviations before adding. If you add the raw deviations, they always sum to zero (or very close, due to rounding), which tells you nothing about spread.
- Rounding too early. Keep at least four decimal places in intermediate steps, especially the mean, or the final answer can drift noticeably.
- Mixing up variance and standard deviation. Variance is the average of the squared deviations; standard deviation is its square root and is in the same units as the original data.
- Using the wrong formula in a spreadsheet.
STDEV.PandSTDEV.Sgive different results; pick the one that matches your data type.
Tips
- Label your columns when working in a spreadsheet: value, deviation, squared deviation. It makes errors easy to spot.
- Use the coefficient of variation (standard deviation divided by the mean) when comparing spread across datasets with different units or very different averages.
- For a quick sanity check, the standard deviation is usually roughly one-quarter to one-third of the range for bell-shaped data, though this is only a rough guide.
- If you only need a rough measure of spread, the range (max − min) is faster, but standard deviation uses every value and is more stable.
- When data has outliers, standard deviation can be inflated; consider reporting the interquartile range alongside it.
Troubleshooting
If your manual result does not match the spreadsheet, first check that you included every value and did not skip or duplicate one. Next, confirm whether you divided by n or n−1 — this is the most common source of a small mismatch. If the numbers are wildly different, look for a data entry error such as a misplaced decimal point or a negative sign dropped. In a spreadsheet, make sure the range in the formula covers exactly the cells you intend; an extra blank cell or a text label in the range can cause an error or an unexpected result. If you get a #DIV/0! error, your range likely contains no numeric values or only one value when using the sample formula. Finally, check that you are using the correct function for your data type: STDEV.P for a population, STDEV.S for a sample.
Frequently Asked Questions
What is the difference between population and sample standard deviation?
Population standard deviation divides the sum of squared deviations by n, the total number of values. Sample standard deviation divides by n−1 to correct for the fact that a sample tends to underestimate the spread of the whole population.
Can standard deviation be negative?
No. It is the square root of a non-negative number (variance), so it is always zero or positive. A standard deviation of zero means every value in the dataset is identical.
What does a high standard deviation mean?
It means the values are spread out over a wider range around the mean. A low standard deviation means the values cluster closely around the mean.
Do I need to square the deviations before averaging?
Yes. Squaring makes all deviations positive and gives more weight to larger differences. Without squaring, positive and negative deviations cancel out.
How many decimal places should I keep?
Keep at least four decimal places during intermediate calculations, then round the final standard deviation to one or two more decimal places than your original data.
Can I calculate standard deviation by hand for large datasets?
It is possible but tedious. For more than about ten values, a spreadsheet or calculator with a standard deviation function is faster and less error-prone.