Article

Standard Deviation: Formula, Examples and Population vs Sample

Standard deviation tells you how widely results are scattered around the mean. This article gives you the formula, explains the difference between dividing by n and by n − 1, and walks through four worked examples and answers to typical questions. You can test your own numbers in the standard deviation calculator.

Last updated:

Related calculations: variance, arithmetic mean and range.

The standard deviation formula

Standard deviation is the square root of the average of the squared deviations from the mean. The larger it is, the more the results differ from the mean. When all numbers are identical, the standard deviation is zero.

σ = √( Σ(xᵢ − m)² ÷ n ) (population)
s = √( Σ(xᵢ − m)² ÷ (n − 1) ) (sample)
m = Σxᵢ ÷ n

SymbolMeaning
marithmetic mean of all numbers
xᵢ − mdeviation of a single number from the mean
Σ(xᵢ − m)²sum of squared deviations
nnumber of values

The calculator returns the population deviation (dividing by n) and shows the sample deviation (dividing by n − 1) for comparison.

Bell curve with mean μ and standard deviation σA normal distribution curve. The shaded area between μ − σ and μ + σ covers about 68% of the values, and the area between μ − 2σ and μ + 2σ about 95%.μμ − σμ + σμ − 2σμ + 2σ≈ 68%≈ 95% within 2σ
For data with a roughly normal distribution, about 68% of the values lie within one standard deviation of the mean and about 95% within two. The calculator itself assumes no particular distribution.

Try it with an example

Example: five scores 6, 7, 7, 9, 11. The list is already stored in the link to the calculator.

Data
6, 7, 7, 9, 11
Mean
8
Σ(x − mean)²
16
Result
σ ≈ 1.7889 (population), s = 2 (sample)

Open the calculator with these numbers

The calculator reads the values from the page address and shows the result right away. You can change them freely.

How the calculator works

You enter a list of at least two numbers, or two numbers in separate fields. The main result is the population standard deviation, that is, division by n. The sample standard deviation, with division by n − 1, is shown next to it for comparison. The calculator also shows the mean, the variance and the sum of squared deviations. It assumes no particular distribution of the data.

How to calculate standard deviation step by step

First find the mean. For the numbers 2, 4, 4, 4, 5, 5, 7, 9 the sum is 40 and the mean is 5. Then subtract the mean from each number and square the result. The sum of those squares is 32.

Divide the sum of squares by n, that is, by 8: 32 ÷ 8 = 4 (this is the variance). The square root of the variance gives the standard deviation σ = 2.

In the calculator you enter a list of numbers, and the result includes the mean, the sum of squared deviations, the population deviation and, for comparison, the sample deviation. For the variance alone use the variance calculator.

Population or sample: dividing by n or n − 1

Divide by n when you have data for the entire population, for example the scores of every student in a class. Divide by n − 1 when the data are a random sample from a larger population and you want to estimate its spread. Dividing by n − 1 gives a slightly larger value, because a sample usually misses the extreme observations.

NumbersMeanσ (divide by n)s (divide by n − 1)
2, 8534.243
2, 4, 4, 4, 5, 5, 7, 9522.138
−2, 0, 2, 412.2362.582

The difference is large for small data sets and shrinks as n grows. At least n = 2 is required for the formula to make sense.

How to interpret the result

The deviation has the same unit as the data. For the numbers 0, 10 the mean is 5 and the deviation is 5: every number lies 5 away from the mean. For the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 the population deviation is about 2.872.

A deviation on its own does not say whether the spread is large. You need to compare it with the mean or with another data set. Simpler measures of spread are the range and the minimum and maximum.

The 68–95–99.7 rule

If the data follow a roughly normal distribution, the standard deviation lets you estimate what share of the values falls within a given range around the mean.

RangeShare of valuesExample: mean 8, σ = 2
mean ± 1σabout 68%6 to 10
mean ± 2σabout 95%4 to 12
mean ± 3σabout 99.7%2 to 14

The rule applies to a normal distribution. For strongly skewed data or data with outliers the shares can differ, and the standard deviation calculator itself does not test whether the distribution is normal.

Coefficient of variation: spread relative to the mean

The coefficient of variation is the standard deviation divided by the mean, expressed as a percentage: CV = σ ÷ mean × 100%. It lets you compare the spread of data with different means or units. For the numbers 6, 7, 7, 9, 11 the mean is 8 and σ ≈ 1.7889, so CV ≈ 22.36%.

The calculator returns the mean and the standard deviation, and you obtain the coefficient of variation by dividing one by the other. When the mean is close to zero, this coefficient loses its meaning.

Standard deviation in Excel and Google Sheets

What you calculateFunctionResult for 6, 7, 7, 9, 11
population standard deviation (divide by n)STDEV.P1.7889
sample standard deviation (divide by n − 1)STDEV.S2.0000

The older STDEV function matches the sample standard deviation. Choose the function according to whether your data cover the whole population or only a sample of it.

Where standard deviation is useful

Grades and test results. Two classes can have the same average but a different spread of grades. A weighted mean is available in the weighted average calculator and is explained in the article Weighted Average: Formula, Examples and Calculator.

Quality control. The deviation of the dimensions of manufactured parts shows how stable the process is.

Finance. The deviation of returns is a basic measure of an investment’s volatility. Changes over time can be calculated in the percentage change calculator.

Scientific measurements. Repeated measurements of the same quantity differ slightly, and the deviation describes by how much. The typical center of a data set is also given by the median.

Four worked examples

You can check each example in the standard deviation calculator.

1. Two numbers: 2 and 8

The simplest data set.

  1. Enter the numbers 2 and 8.
  2. The mean is 5 and the deviations are −3 and 3.
  3. The sum of squares is 9 + 9 = 18, and divided by 2 it gives 9.
  4. The square root gives σ = 3; the sample deviation is about 4.243.

2. Eight numbers: 2, 4, 4, 4, 5, 5, 7, 9

A classic example from statistics textbooks.

  1. The numbers add up to 40, so the mean is 5.
  2. The sum of squared deviations is 32.
  3. The variance is 32 ÷ 8 = 4.
  4. The population deviation is σ = 2 and the sample deviation is about 2.138.

3. Negative and positive numbers: −2, 0, 2, 4

Values on both sides of zero.

  1. The numbers add up to 4, so the mean is 1.
  2. The deviations are −3, −1, 1 and 3, and the sum of their squares is 20.
  3. The variance is 20 ÷ 4 = 5.
  4. The population deviation is about 2.236 and the sample deviation is about 2.582.

4. Range from 0 to 10: 0, 10

Extreme values with few data points.

  1. The mean is 5 and the deviations are −5 and 5.
  2. The sum of squares is 50 and the variance is 25.
  3. The population deviation is 5.
  4. The sample deviation is larger, about 7.071.

Common mistakes with standard deviation

  • Confusing a population with a sample — dividing by n and by n − 1 gives different results, so you need to know what kind of data you have.
  • Leaving out the square root — the sum of squares divided by n is the variance, and the standard deviation is its square root.
  • Adding deviations without squaring — positive and negative deviations cancel out, so the sum is zero.
  • Using a single number — a deviation needs at least two values.
  • Giving the result without a unit — the deviation has the unit of the data, such as points, kilograms or dollars.
  • Comparing sets in different units — deviations of sets measured in different units are not comparable.
  • Rounding too early — round only the final result, especially the mean.

Frequently asked questions

How do you calculate standard deviation?

Find the mean, subtract it from each number, square the differences, add them up, divide by n and take the square root. For 2 and 8 the result is 3.

What is the difference between population and sample standard deviation?

The population deviation divides the sum of squares by n, and the sample deviation divides by n − 1. The sample deviation is slightly larger.

When should you divide by n − 1?

When the data are a sample from a larger population and you want to estimate its spread.

What is variance?

It is the square of the standard deviation, that is, the sum of squared deviations divided by n. For the numbers 2, 4, 4, 4, 5, 5, 7, 9 it is 4.

What is the standard deviation of the numbers 1 to 10?

The population deviation is about 2.872 and the sample deviation is about 3.028.

Can standard deviation be negative?

No. It is the square root of a sum of squares, so it is never negative. It equals zero only when all numbers are the same.

What is the standard deviation of 5, 9, 8, 12, 6, 10, 6, 8?

The mean is 8 and the sum of squared deviations is 38. The population standard deviation is √(38 ÷ 8) ≈ 2.1794, and the sample standard deviation is √(38 ÷ 7) ≈ 2.3299.

What does a large standard deviation mean?

The results are widely scattered around the mean. A small deviation means the values lie close to the mean.

Calculate the deviation of your own data

Enter a list of numbers in the standard deviation calculator to see the mean, the sum of squared deviations and the deviation. If you have only three values, the three-number calculator is handy.

To complete the analysis use the arithmetic mean, the median and the variance.