Uni-Sine
MathematicsStatistics

Variance calculator: sample and population variance with working

Variance is the average of the squared distances from the mean. Divide the sum of squared distances by n − 1 for a sample, or by n for a population. Our variance calculator is part of the Standard Deviation Calculator: enter your data and it gives the variance with the full working, alongside the standard deviation, which is the variance's square root.

Try it

Standard Deviation Calculator

Find the standard deviation and variance of any data set

Go to its page

How to find the variance with the calculator

  1. Open the Standard Deviation Calculator. There is no separate switch for variance: it is always worked out.
  2. Choose Raw data, Frequency or Grouped, then type or paste your values into the table.
  3. Under This data is a, choose Sample or Population.
  4. Read the second result, Sample variance (s²) or Population variance (σ²).
  5. The working table lists every squared distance, and the third step of the working shows the division that gives the variance.

The variance formula

s^2 = \frac{\Sigma(x - \bar{x})^2}{n - 1} \qquad \sigma^2 = \frac{\Sigma(x - \mu)^2}{n}Sample variance (left) and population variance (right)

The top of each fraction is the same: the sum of squared deviations, often shortened to the sum of squares. Only the bottom changes. Use the population formula when your data is the whole group you care about, and the sample formula when it is part of a bigger group. Dividing a sample by n − 1 corrects for the fact that a sample sits closer to its own mean than to the true mean, which would make the variance look too small. The NIST handbook defines it this way.

The shortcut formula for variance

Working out every deviation is slow by hand, especially when the mean is a messy decimal. This version gives the same answer from just Σx and Σx²:

\sigma^2 = \frac{\Sigma x^2}{n} - \mu^2 \qquad s^2 = \frac{\Sigma x^2 - n\bar{x}^2}{n - 1}

In words, for a population: the mean of the squares minus the square of the mean. Exam questions, especially in A-level Maths, often give you Σx and Σx² instead of the raw data, and then this is the only way in.

Worked examples you can check in the calculator

Example 1: sample variance

Five plants from a tray are measured, in centimetres: 3, 7, 8, 10 and 12. Find the sample variance.

xx − x̄(x − x̄)²
3−525
7−11
800
1024
12416
Total 40046
\bar{x} = \frac{40}{5} = 8 \qquad s^2 = \frac{46}{5 - 1} = 11.5

The sample variance is 11.5 cm². Switch the calculator to Population and it shows σ² = 46 ÷ 5 = 9.2 cm² instead. The standard deviation is the square root: s = 3.39 cm.

Example 2: population variance with the shortcut

Find the population variance of 2, 4, 5 and 9. Here n = 4, Σx = 20, so μ = 5, and Σx² = 4 + 16 + 25 + 81 = 126.

\sigma^2 = \frac{126}{4} - 5^2 = 31.5 - 25 = 6.5

The population variance is 6.5. The long way agrees: the deviations are −3, −1, 0 and 4, their squares add to 26, and 26 ÷ 4 = 6.5.

Example 3: variance of a frequency table

16 students picked at random say how many hours they slept last night. Choose Frequency in the calculator and enter each x with its f.

Hours xStudents ffxfx²
521050
6530180
7642294
8324192
Total16106716

The mean is 106 ÷ 16 = 6.625 hours. It is a sample, so use the sample shortcut:

s^2 = \frac{716 - 16 \times 6.625^2}{16 - 1} = \frac{716 - 702.25}{15} = 0.917

The sample variance is 0.917 hours² to 3 significant figures. Notice that n is the total of the frequencies, 16, and not the number of rows.

Example 4: variance of a dice roll

A fair dice (die in the US) lands on 1, 2, 3, 4, 5 or 6, each equally likely. These six outcomes are the whole population, so divide by n. The mean is 3.5, the squared deviations are 6.25, 2.25, 0.25, 0.25, 2.25 and 6.25, and they add to 17.5.

\sigma^2 = \frac{17.5}{6} = 2.917

As a fraction this is 35/12, a value that comes up again when you meet discrete random variables in statistics.

Try one

practice
Pick an answer, then check it.
A sample has a standard deviation of 4 cm. What is its variance?

Variance vs standard deviation

They carry the same information: the standard deviation is the square root of the variance, and the variance is the standard deviation squared. The difference is the units. Square centimetres and hours² are hard to picture, so to describe spread in words, use the standard deviation. Variance is the one used inside calculations, because variances of independent quantities add together and standard deviations do not. The standard deviation calculator guide covers reading the spread and the empirical rule.

Common mistakes

  • Taking a square root at the end. That gives the standard deviation. Variance stops before the root.
  • Dividing by the wrong number. n − 1 for a sample, n for a population.
  • Squaring the sum instead of summing the squares. Σx² means square each value, then add. (Σx)² means add, then square.
  • Forgetting to square the mean in the shortcut formula: it is Σx²/n − μ², not Σx²/n − μ.
  • Rounding the mean before using the shortcut. Σx²/n and μ² are often close, so a rounded mean can throw the answer out badly.
  • Writing the wrong units. Variance is in the data's units squared.

Common questions

How do you calculate variance step by step?
Find the mean, subtract it from each value, square each result, add the squares, and divide by n − 1 for a sample or n for a population.
What is the difference between sample and population variance?
Only the divisor. Sample variance divides the sum of squares by n − 1, and population variance divides by n. Sample variance is always a little bigger for the same data.
Can variance be negative?
No. It is built from squares, which are never negative, so the smallest possible variance is 0, when every value is the same. A negative answer from the shortcut formula means a mistake, usually a rounded mean.
How do I get variance from standard deviation?
Square it. A standard deviation of 4 cm means a variance of 16 cm².
Does the calculator work for grouped data?
Yes. Choose Grouped and enter each class with its frequency. It uses each class midpoint, so the variance is an estimate, and the calculator labels it as one.

Revision cards

Read the front, say your answer, then flip to check.

Where to go next

  • Solve it

    Standard Deviation Calculator

    Find the standard deviation and variance of any data set

    Open the tool
  • Test it

    AP Statistics

    A new exam-style paper every day, with instant marking and a mark scheme

    Start today's paper
Read next
Maths · StatisticsStandard deviation calculator: sample and populationFind the sample or population standard deviation of raw data, a frequency table or grouped data, with the full working table and worked examples.