Learn Chinese, Math, English ELA online with WuKong Education!
Book A Free Trial Class Now
Site icon WuKong Edu Blog

Variance Formula: Population, Sample, Calculator and Examples

math

Quick Answer: What Is the Variance Formula?

Variance measures how far a set of data values spreads out from the mean. A small variance means the values are close to the mean, while a large variance means the values are more spread out.

There are two main variance formulas:

Type of varianceFormulaUse when
Population varianceσ² = Σ(xᵢ – μ)² / NYou have data for every member of the group
Sample variances² = Σ(xᵢ – x̄)² / (n – 1)You have only a sample and want to estimate the population variance

In these formulas:

Discovering the maths whiz in every child,
that’s what we do.

Suitable for students worldwide, from grades 1 to 12.

Get started free!

To calculate variance, find the mean, subtract the mean from each value, square each difference, add the squared differences, and divide by N for population variance or n – 1 for sample variance.

Variance Formula: Population vs Sample

The formula you use depends on whether your data represents an entire population or only a sample.

If you collect the test scores of every student in one class, you can use the population variance formula because you have the full group. If you collect scores from only 20 students to estimate the performance of a much larger grade level, you should use the sample variance formula.

FeaturePopulation varianceSample variance
Symbolσ²
Mean usedμ
DenominatorNn – 1
Best forComplete data setPartial data set
Common exampleHeights of all students in one classHeights of 30 students chosen from a school

The most important difference is the denominator. Population variance divides by N, while sample variance divides by n – 1. This adjustment helps a sample give a better estimate of the population’s true variance.

Population Variance FormulaSample Variance Formula
σ² = Σ(x_i – μ)² / Ns² = Σ(x_i – x̄)² / (n – 1)

Online Variance Calculator

Step-by-Step Variance Lab

Learn how to calculate Variance & Standard Deviation

Step 1: Calculate the Mean (μ or x̄)
Step 2: Find Squared Differences
x (x – mean) (x – mean)²
Final Results
Interactive Statistics Tool by Wukong Education

How to Calculate Variance in 5 Steps?

You can calculate variance by following the same basic steps every time.

Step 1: Find the mean

Add all values together and divide by the number of values.

For the data set 8, 12, 10, 14, 16:

Mean = (8 + 12 + 10 + 14 + 16) / 5

Mean = 60 / 5

Mean = 12

Step 2: Subtract the mean from each value

Find how far each value is from the mean.

ValueValue – mean
8-4
120
10-2
142
164

Step 3: Square each difference

Squaring removes negative signs and gives more weight to values that are farther from the mean.

ValueDifferenceSquared difference
8-416
1200
10-24
1424
16416

Step 4: Add the squared differences

16 + 0 + 4 + 4 + 16 = 40

The sum of squared differences is 40.

Step 5: Divide by N or n – 1

For population variance:

σ² = 40 / 5 = 8

For sample variance:

s² = 40 / (5 - 1) = 10

So the population variance is 8, and the sample variance is 10.

Population Variance Formula

The population variance formula is:

σ² = Σ(xᵢ - μ)² / N

Use this formula when your data set includes every member of the population you are studying.

Population Variance Example

Suppose five students took a quiz, and these are all the scores in the class:

6, 8, 10, 12, 14

First, find the mean:

μ = (6 + 8 + 10 + 12 + 14) / 5 μ = 50 / 5 μ = 10

Next, subtract the mean and square each difference:

ScoreScore – meanSquared difference
6-416
8-24
1000
1224
14416

Add the squared differences:

16 + 4 + 0 + 4 + 16 = 40

Divide by N:

σ² = 40 / 5 = 8

The population variance is 8.

Sample Variance Formula

The sample variance formula is:

s² = Σ(xᵢ - x̄)² / (n - 1)

Use this formula when your data set is only a sample from a larger population.

Sample Variance Example

A teacher randomly selects five students from a larger grade level and records their test scores:

78, 82, 85, 88, 90

Find the sample mean:

x̄ = (78 + 82 + 85 + 88 + 90) / 5 x̄ = 423 / 5 x̄ = 84.6

Now calculate the squared differences:

ScoreScore – meanSquared difference
78-6.643.56
82-2.66.76
850.40.16
883.411.56
905.429.16

Add the squared differences:

43.56 + 6.76 + 0.16 + 11.56 + 29.16 = 91.2

Divide by n – 1:

s² = 91.2 / (5 - 1) s² = 91.2 / 4 s² = 22.8

The sample variance is 22.8.

Why Does Sample Variance Use n – 1?

Sample variance uses n – 1 because a sample usually underestimates how spread out the full population is.

When you calculate the sample mean, the values in the sample are already centered around that sample mean. This often makes the sample look slightly less spread out than the full population. Dividing by n – 1 instead of n makes the variance a little larger, which helps correct that underestimation.

This adjustment is called Bessel’s correction.

For students, the simple rule is:

Variance vs Standard Deviation

Variance and standard deviation both measure spread, but they are reported in different units.

Variance is measured in squared units. Standard deviation is the square root of variance, so it uses the same units as the original data.

MeasureFormulaUnitMeaning
VarianceAverage squared distance from the meanSquared unitsMeasures overall spread
Standard deviationSquare root of varianceOriginal unitsEasier to interpret

For example, if exam scores have a variance of 25 points squared, the standard deviation is:

√25 = 5

That means scores typically vary by about 5 points from the mean.

Alternative Variance Formula

Another useful formula for variance is:

Var(X) = E(X²) - [E(X)]²

This means:

Variance = mean of the squares - square of the mean

For a data set, the population version can be written as:

σ² = [Σxᵢ² / N] - μ²

This formula is often faster when you already know the sum of the values and the sum of the squared values.

Alternative Formula Example

For the data set:

2, 4, 6

Find the mean:

μ = (2 + 4 + 6) / 3 = 4

Find the mean of the squares:

(2² + 4² + 6²) / 3 = (4 + 16 + 36) / 3 = 56 / 3 = 18.67

Subtract the square of the mean:

18.67 - 4² = 18.67 - 16 = 2.67

The population variance is about 2.67.

Variance Formula for Grouped Data

When data is organized in a frequency table, use the grouped data variance formula.

For population variance:

σ² = Σf(x - μ)² / N

For sample variance:

s² = Σf(x - x̄)² / (n - 1)

In these formulas:

Grouped Data Example

Suppose the table shows how many students earned each score:

ScoreFrequency
702
803
905

First, find the mean:

Mean = (70 × 2 + 80 × 3 + 90 × 5) / (2 + 3 + 5)

Mean = (140 + 240 + 450) / 10

Mean = 830 / 10 = 83

Then calculate the squared differences with frequency:

ScoreFrequencyScore – meanSquared differencef × squared difference
702-13169338
803-3927
905749245

Add the weighted squared differences:

338 + 27 + 245 = 610

Population variance:

σ² = 610 / 10 = 61

The population variance is 61.

How to Find Variance in Excel, Google Sheets, and Python

Many students and teachers calculate variance using spreadsheets or programming tools.

Excel and Google Sheets

Use these functions:

FunctionMeaning
=VAR.P(A1:A10)Population variance
=VAR.S(A1:A10)Sample variance
=STDEV.P(A1:A10)Population standard deviation
=STDEV.S(A1:A10)Sample standard deviation

Use VAR.P when your data is the full population. Use VAR.S when your data is a sample.

Python

In Python, you can use NumPy:

import numpy as np data = [8, 12, 10, 14, 16]

population_variance = np.var(data)

sample_variance = np.var(data, ddof=1) print(population_variance) print(sample_variance)

The ddof=1 setting tells Python to divide by n – 1, which gives the sample variance.

Low Variance vs High Variance

Variance helps you understand whether values are consistent or widely spread out.

Variance levelWhat it meansExample
Low varianceValues are close to the meanTest scores of 88, 89, 90, 91, 92
High varianceValues are far from the meanTest scores of 60, 75, 90, 95, 100

Low variance often suggests consistency. High variance suggests more variability or less predictability.

For example, two classes may have the same average score, but one class may have much higher variance. That means students in that class performed very differently from one another, even if the average score looks normal.

Common Mistakes When Calculating Variance

Mistake 1: Using n instead of n – 1 for a sample

If your data is a sample, use n – 1 in the denominator. Using n will usually make the variance too small.

Mistake 2: Forgetting to square the differences

If you add the differences without squaring them, positive and negative values can cancel out. Squaring makes every difference positive.

Mistake 3: Confusing variance with standard deviation

Variance is in squared units. Standard deviation is in the original units. If you need an easier real-world interpretation, standard deviation is often more useful.

Mistake 4: Choosing the wrong mean

Use μ for population variance and x̄ for sample variance. The calculation is similar, but the meaning is different.

Discovering the maths whiz in every child,
that’s what we do.

Suitable for students worldwide, from grades 1 to 12.

Get started free!
Exit mobile version