How to Calculate Standard Deviation (Step by Step)

|
math statistics

Standard deviation measures how far a set of numbers spreads out from its mean. The formulas for population and sample standard deviation are:

\[\sigma = \sqrt{\frac{\sum (x_i - \mu)^2}{N}}\] \[s = \sqrt{\frac{\sum (x_i - \bar{x})^2}{N - 1}}\]

The first formula uses the full population count N. The second divides by N - 1 instead, which corrects for the bias introduced when estimating spread from a sample rather than a complete population. Both formulas follow the same sequence of steps: find the mean, measure each value’s distance from it, square those distances, average them, and take the square root.

Worked example with six values

Start with this data set: 4, 8, 6, 5, 3, 10. There are six values.

First, find the mean. Add the values and divide by the count.

\[\bar{x} = \frac{4 + 8 + 6 + 5 + 3 + 10}{6} = \frac{36}{6} = 6\]

If the mean is unfamiliar, how to calculate mean, median, and mode covers all three averages with examples.

Next, subtract the mean from each value and square the result.

Value (x) Deviation (x - mean) Squared deviation
4 4 - 6 = -2 4
8 8 - 6 = 2 4
6 6 - 6 = 0 0
5 5 - 6 = -1 1
3 3 - 6 = -3 9
10 10 - 6 = 4 16

Squaring eliminates negative signs. Without squaring, the deviations would sum to zero every time (the negatives and positives cancel out), which would tell you nothing about spread.

Then sum the squared deviations.

\[\sum (x_i - \bar{x})^2 = 4 + 4 + 0 + 1 + 9 + 16 = 34\]

Finally, divide and take the square root.

For the population standard deviation, divide by N:

\[\sigma = \sqrt{\frac{34}{6}} = \sqrt{5.667} = \textbf{2.38}\]

For the sample standard deviation, divide by N - 1:

\[s = \sqrt{\frac{34}{5}} = \sqrt{6.8} = \textbf{2.61}\]

The standard deviation calculator runs through these same steps instantly and also returns the variance, median, and range.

Population vs. sample: when to use each formula

If your data set contains every member of the group you care about, use the population formula (divide by N). An example would be calculating the standard deviation of test scores for every student in a class of 30. You have all the data, so there is no estimation involved.

If your data is a subset drawn from a larger group, use the sample formula (divide by N - 1). Surveying 200 customers out of 50,000 is a sample. Measuring the height of 40 trees in a forest with thousands of trees is a sample. Dividing by N - 1 instead of N is called Bessel’s correction. It compensates for the fact that a sample tends to cluster closer to its own mean than to the true population mean, which would cause a straight division by N to slightly underestimate the real spread.

In practice, the difference between N and N - 1 shrinks as the data set grows. With 500 values, dividing by 500 vs. 499 barely changes the result. With 5 values, it matters more. When in doubt, most statistics courses and software default to the sample formula.

Two data sets with the same mean, different spread

Standard deviation is useful precisely because the mean alone does not tell the full story. Consider two sets of quiz scores:

  Values Mean Population SD
Class A 70, 75, 80, 85, 90 80 7.07
Class B 40, 60, 80, 100, 120 80 28.28

Both classes average 80, but Class B’s scores are spread across a much wider range. The standard deviation of 28.28 vs. 7.07 quantifies that difference. A teacher looking only at the mean would conclude the two classes performed identically, which is clearly not the case. The mean tells you the center; standard deviation tells you how tightly the values cluster around that center.

The 68-95-99.7 rule

For data that follows a normal distribution (the bell curve), standard deviation maps directly to percentages of the population:

Range Percentage of data
Within 1 SD of the mean 68.3%
Within 2 SD of the mean 95.4%
Within 3 SD of the mean 99.7%

If exam scores have a mean of 75 and a standard deviation of 10, then roughly 68% of students scored between 65 and 85, about 95% scored between 55 and 95, and nearly all students scored between 45 and 105. Scores outside three standard deviations are extremely rare. This property is why standard deviation is central to grading curves, quality control thresholds, and scientific confidence intervals.

To convert a specific value into its exact position within the distribution, you calculate its z-score, which tells you how many standard deviations it falls above or below the mean. A score of 92 on the exam above has a z-score of (92 - 75) / 10 = 1.7, meaning it is 1.7 standard deviations above average. The z-score calculator converts any value into its z-score and corresponding percentile.

Variance vs. standard deviation

Variance is the squared version of standard deviation. In the worked example above, the population variance is 5.667 and the sample variance is 6.8. Standard deviation is just the square root of variance, which brings the measurement back to the same units as the original data.

If the data represents heights in centimeters, the variance is in “square centimeters,” which is not a meaningful unit. The square root returns the result to centimeters, making it directly interpretable. This is the main reason standard deviation is reported far more often than variance in everyday use, even though variance is mathematically simpler to work with in formulas.

Common mistakes

The most frequent error is forgetting to square the deviations before summing them. Without squaring, the sum of deviations from the mean is always zero. If you get zero and your data is not a set of identical values, you skipped the squaring step.

Another common mistake is using the population formula on sample data. If you collected data from a subset of a larger group, dividing by N instead of N - 1 will give a standard deviation that is slightly too low. For small samples (under 30 values), this difference is large enough to matter.

Finally, watch for outliers. A single extreme value can inflate the standard deviation substantially. The data set {10, 12, 11, 13, 50} has a mean of 19.2 and a population standard deviation of 15.43, driven almost entirely by that one value of 50. The mean, median, and mode calculator can help identify whether your central tendency is being pulled by outliers before you interpret the standard deviation.