Skip to content
  • Open the math solver
  • Ask the AI tutor
  • Find an AP course
  • Create a quiz
  • Open the calculator
  • Graphing Calculator
  • Browse all calculators
  • Read math guides
↑ ↓Enter to open · Esc to close
Solve a problem

Statistics

How to Calculate Standard Deviation (Sample and Population)

By MathSolver Pro Editorial Team · Published

Standard deviation measures how far data values typically lie from their mean. This guide walks through the calculation step by step, explains when to divide by n and when by n minus 1, and shows how to read the answer once you have it.

What standard deviation measures

The mean tells you where the centre of a data set is, but not how tightly the values cluster around it. Standard deviation fills that gap. A small standard deviation means the values sit close to the mean; a large one means they are widely scattered. It is measured in the same units as the data, so a standard deviation of 5 centimetres for heights means a typical height is roughly 5 centimetres from the average.

The calculation follows a simple logic. Measure how far each value is from the mean, square those distances so that values above and below the mean do not cancel out, average the squares, and finally take the square root to return to the original units. If you need a refresher on the mean itself, start with mean, median, mode and standard deviation.

The two formulas

There are two versions, depending on whether your data are an entire population or a sample drawn from a larger population:

σ=∑(xi−μ)2Ns=∑(xi−xˉ)2n−1\sigma = \sqrt{\frac{\sum (x_i - \mu)^2}{N}} \qquad s = \sqrt{\frac{\sum (x_i - \bar{x})^2}{n - 1}}

The population standard deviation σ\sigma divides by the number of values NN. The sample standard deviation ss divides by n−1n - 1. The quantity under the square root is the variance, written σ2\sigma^2 or s2s^2. Variance is useful in theory, but its units are squared, such as square centimetres, which is why the standard deviation is the number usually reported.

Five steps, worked by hand

Example 1: standard deviation of five values

  1. Data: 6, 8, 10, 12, 14. Step 1, find the mean: 505=10\frac{50}{5} = 10.
  2. Step 2, subtract the mean from each value: −4,−2,0,2,4-4, -2, 0, 2, 4.
  3. Step 3, square each deviation: 16,4,0,4,1616, 4, 0, 4, 16.
  4. Step 4, add the squares: 16+4+0+4+16=4016 + 4 + 0 + 4 + 16 = 40.
  5. Step 5, divide and take the square root. As a population: σ=405=8≈2.83\sigma = \sqrt{\frac{40}{5}} = \sqrt{8} \approx 2.83. As a sample: s=404=10≈3.16s = \sqrt{\frac{40}{4}} = \sqrt{10} \approx 3.16.

A table with columns for xx, x−xˉx - \bar{x} and (x−xˉ)2(x - \bar{x})^2 keeps the work organised. A useful check is that the deviations in the second column always add up to zero. If they do not, the mean is wrong, and everything after it will be wrong too.

Why divide by n minus 1 for a sample?

When you work with a sample, you do not know the true population mean, so you measure deviations from the sample mean instead. The sample mean is, by its construction, the point that makes the sum of squared deviations as small as possible for that particular sample. Deviations measured from it are therefore slightly smaller, on average, than deviations from the true mean would be.

Dividing by n−1n - 1 instead of nn corrects for that, making the sample variance an unbiased estimate of the population variance. This adjustment is called Bessel's correction. Another way to see it is through degrees of freedom: once you know the mean and n−1n - 1 of the deviations, the last deviation is forced, because they must add to zero. Only n−1n - 1 deviations carry independent information.

In practice, use the sample formula unless your data genuinely include every member of the group you care about, such as the scores of every student in one class when you only care about that class.

A shortcut formula and frequency tables

An algebraically equivalent formula avoids computing each deviation separately:

σ2=∑xi2N−μ2\sigma^2 = \frac{\sum x_i^2}{N} - \mu^2

For the data in Example 1, ∑x2=36+64+100+144+196=540\sum x^2 = 36 + 64 + 100 + 144 + 196 = 540, so σ2=5405−102=8\sigma^2 = \frac{540}{5} - 10^2 = 8, as before. The shortcut is quick by hand, but computers avoid it with large or very precise numbers, because subtracting two nearly equal large numbers loses accuracy.

Example 2: data in a frequency table

  1. A survey records the number of pets in 10 homes: the value 1 appears 2 times, 2 appears 5 times and 3 appears 3 times.
  2. Mean: 1(2)+2(5)+3(3)10=2110=2.1\frac{1(2) + 2(5) + 3(3)}{10} = \frac{21}{10} = 2.1.
  3. Weighted squared deviations: 2(1−2.1)2+5(2−2.1)2+3(3−2.1)2=2.42+0.05+2.43=4.92(1 - 2.1)^2 + 5(2 - 2.1)^2 + 3(3 - 2.1)^2 = 2.42 + 0.05 + 2.43 = 4.9.
  4. As a sample: s=4.99≈0.738s = \sqrt{\frac{4.9}{9}} \approx 0.738. As a population: σ=4.910=0.7\sigma = \sqrt{\frac{4.9}{10}} = 0.7.

Interpreting the result

For data that follow a roughly bell-shaped normal distribution, the empirical rule gives a concrete reading of the standard deviation: about 68 percent of values lie within one standard deviation of the mean, about 95 percent within two and about 99.7 percent within three. If adult heights in a group have mean 170 centimetres and standard deviation 8, roughly 95 percent of the group is between 154 and 186 centimetres tall.

For data of any shape, Chebyshev's inequality still guarantees that at least 75 percent of values lie within two standard deviations of the mean, and at least about 89 percent within three. Expressing a single value's distance from the mean in standard deviations gives its z-score, which lets you compare values measured on different scales.

Standard deviation also responds predictably to changes in the data. Adding the same constant to every value shifts the mean but leaves the standard deviation unchanged, because the spread is the same. Multiplying every value by a constant multiplies the standard deviation by the absolute value of that constant, so converting metres to centimetres multiplies it by 100.

Using a calculator or spreadsheet

Scientific calculators usually show two keys, often labelled σx\sigma_x or σn\sigma_n for the population version and sxs_x or σn−1\sigma_{n-1} for the sample version. In spreadsheets such as Excel and Google Sheets, STDEV.P computes the population standard deviation and STDEV.S the sample one; the older STDEV function also gives the sample value. Choosing the wrong one is the most common source of mismatched answers.

The standard deviation calculator shows both versions together with the full deviation table, which is ideal for checking homework done by hand. The mean, median and mode calculator adds the other summary statistics, and the z-score calculator uses the result to standardise individual values.

Comparing spread across different scales

Standard deviations are hard to compare when the means are very different. A standard deviation of 2 kilograms is large for newborn babies but tiny for adult elephants. The coefficient of variation solves this by dividing the standard deviation by the mean, often expressed as a percentage. Two investments with average yearly returns of 6 and 9 percent and standard deviations of 3 and 9 percentage points have coefficients of variation of 50 and 100 percent, so the second is twice as volatile relative to its typical return.

Common mistakes

  • Forgetting to square the deviations, so that positive and negative values cancel to zero.
  • Forgetting the final square root and reporting the variance instead.
  • Mixing the sample and population formulas, or pressing the wrong calculator key.
  • Rounding the mean heavily before computing deviations, which compounds rounding error.
  • Treating a frequency table as if each value appeared once.

Frequently asked questions

Should I use the sample or population standard deviation?

Use the population formula only when your data include every member of the group you want to describe. If the data are a sample used to learn about a larger group, which is the usual situation, use the sample formula with n−1n - 1.

Why take a square root of the variance at all?

Variance is the average squared deviation from the mean, and standard deviation is its square root. They contain the same information, but standard deviation is in the original units, so it is easier to interpret.

What does a standard deviation of zero mean?

Every value in the data set is identical, so there is no spread at all. Any variation at all makes the standard deviation positive.

Is a large standard deviation bad?

Not necessarily. It simply means the data are spread out. Whether that is good depends on context: wide variation in delivery times is bad, while wide variation in a plant breeding trial may be exactly what a researcher hopes to find.

MathSolver Pro Editorial Team

Math content and review

Our editorial team writes every guide to explain the reasoning behind each method, not just the answer. Each worked example is checked against the site's own solver engines and automated tests before it is published, and articles are revised whenever a method or an exam format changes.