Skip to content
CalcWorld

Browse all tools

Variance Calculator

This variance calculator finds the average of the squared differences from the mean, for a sample or for a whole population. For delivery times of 10, 12, 23, 23, 16, 23, 21 and 16 minutes the mean is 18 and the sample variance is 27.43.

Sources: OpenStax Introductory Statistics 2e Updated

Separate the values with commas, spaces or new lines.
The data is a

Sample variance (s²)

≈ 6.166667

Sample standard deviation (s)
2.483277
Mean
5.166667
Count (n)
6
Sum of squares
30.833333
Population variance (σ²)
5.138889
Show steps Here’s how we got it
  1. Count the values

    n = 6

  2. Find the mean

    (2 + 4 + 4 + 5 + 7 + 9) ÷ 6 = 31 ÷ 6 ≈ 5.166667

    The mean is the sum divided by how many values there are.

  3. Subtract the mean from each value, then square the result

    Value xx − mean(x − mean)2
    2−3.166710.0278
    4−1.16671.3611
    4−1.16671.3611
    5−0.16670.0278
    71.83333.3611
    93.833314.6944
    Sum30.8333

    Squaring makes every difference positive, so values below the mean do not cancel values above it.

  4. Add up the squared differences

    Sum of squares ≈ 30.833333

  5. Divide by n − 1

    30.833333 ÷ (6 − 1) = 30.833333 ÷ 5 ≈ 6.166667

    This is the sample variance. The values in a sample sit closer to their own mean than to the true population mean, so dividing by n would come out too small. Dividing by n − 1 corrects for that.

The variance formulas

For a sample of n values with mean xˉ\bar{x}:

s2=∑(x−xˉ)2n−1s^2 = \frac{\sum (x - \bar{x})^2}{n - 1}

For a whole population of N values with mean μ\mu:

σ2=∑(x−μ)2N\sigma^2 = \frac{\sum (x - \mu)^2}{N}

The top of each fraction is called the sum of squares. These are the definitions in OpenStax Introductory Statistics.

How to calculate variance: eight delivery times

A sample of eight delivery times, in minutes: 10, 12, 23, 23, 16, 23, 21 and 16.

  1. Count the values

    n = 8

  2. Find the mean

    (10 + 12 + 23 + 23 + 16 + 23 + 21 + 16) ÷ 8 = 144 ÷ 8 = 18

    The mean is the sum divided by how many values there are.

  3. Subtract the mean from each value, then square the result

    Value xx − mean(x − mean)2
    10−864
    12−636
    23525
    23525
    16−24
    23525
    2139
    16−24
    Sum192

    Squaring makes every difference positive, so values below the mean do not cancel values above it.

  4. Add up the squared differences

    Sum of squares = 192

  5. Divide by n − 1

    192 ÷ (8 − 1) = 192 ÷ 7 ≈ 27.428571

    This is the sample variance. The values in a sample sit closer to their own mean than to the true population mean, so dividing by n would come out too small. Dividing by n − 1 corrects for that.

Answer: ≈ 27.428571

Variance calculator example: the delivery times 10, 12, 16, 16, 21, 23, 23, 23 drawn as squares of their distance from the mean 18, with areas 64, 36, 4, 4, 9, 25, 25 and 25 adding up to 192; 192 ÷ 7 = 27.4286.
The two shortest deliveries, 10 and 12 minutes, give the two biggest squares: 100 of the 192.

Sample variance, population variance and standard deviation

The same eight times give a sample variance of 192 ÷ 7 = 27.43 and a population variance of 192 ÷ 8 = 24. Divide by n − 1 when the eight deliveries stand in for many more; divide by n when they are all the deliveries you care about.

The square root of the sample variance is the sample standard deviation, √27.43 = 5.24 minutes, back in the units of the data. The standard deviation calculator shows that last step.

Why one long or short value matters so much

Squaring makes big differences count far more than small ones: the 10-minute delivery is 8 minutes from the mean and adds 64, while the two 16-minute ones add 4 each. A single unusual value can raise the variance a lot.

When the data has outliers, the interquartile range is a steadier measure of spread. Variance is still the one used inside other methods, such as the least-squares line in the linear regression calculator.

Variance practice question

Find the population variance of 4, 8, 6, 5, 3 and 4.

Check your answer

Answer: ≈ 2.666667

  1. Count the values

    n = 6

  2. Find the mean

    (4 + 8 + 6 + 5 + 3 + 4) ÷ 6 = 30 ÷ 6 = 5

    The mean is the sum divided by how many values there are.

  3. Subtract the mean from each value, then square the result

    Value xx − mean(x − mean)2
    4−11
    839
    611
    500
    3−24
    4−11
    Sum16

    Squaring makes every difference positive, so values below the mean do not cancel values above it.

  4. Add up the squared differences

    Sum of squares = 16

  5. Divide by n

    16 ÷ 6 ≈ 2.666667

    This is the population variance: the average squared distance from the mean.

Questions about variance

How do you calculate variance?

Find the mean, subtract it from each value, square each difference and add the squares. Divide the total by n − 1 for a sample or by n for a population.

What is the difference between sample variance and population variance?

Population variance divides the sum of squares by n and is used when the data covers the whole group. Sample variance divides by n − 1 and is used when the data is a sample from a larger group.

Why are the differences squared?

Without squaring, the differences above the mean and below the mean would cancel and always add up to zero. Squaring makes every term positive and gives more weight to values far from the mean.

What units does variance have?

The square of the data's units. If the data is in centimetres, the variance is in square centimetres. Take the square root, the standard deviation, to get back to the original units.

Can variance be negative?

No. It is a sum of squares divided by a positive number, so the smallest it can be is 0, which happens only when every value is the same.

Sources