Variance

Lesson 7 of 20, about 17 minutes

What you will learn

  • Explain what variance measures about a set of numbers
  • Understand why simply adding the deviations from the mean gives zero
  • Understand why variance squares the deviations
  • Calculate the variance of a small dataset step by step

The mean tells you the center. But two very different sets of numbers can share the same center. The returns 5, 5, 5 and the returns negative 20, 5, 30 both average to about the same place, yet one is perfectly steady and the other swings wildly. To capture that difference, we need a measure of spread, of how far the values tend to stray from the mean. Variance is that measure, and this lesson takes its formula apart piece by piece so it makes sense.

Calculating the mean, variance, and standard deviation (StatQuest)

Josh Starmer walks from the mean to variance with clear intuition. Watch how the squared spread captures how far values sit from the center.

Start with the deviations from the mean

Spread is about distance from the mean, so the natural first step is to find each value's deviation, meaning how far it sits from the mean. Take the numbers 2, 4, 6, and 8, whose mean is 5. The deviations are 2 minus 5 which is negative 3, 4 minus 5 which is negative 1, 6 minus 5 which is 1, and 8 minus 5 which is 3. Values below the mean give negative deviations, and values above give positive ones.

Why you cannot just add the deviations

Here is the first puzzle. It seems natural to just average the deviations to get a typical distance from the mean. But watch what happens when you add them: negative 3 plus negative 1 plus 1 plus 3 equals zero. This is not a coincidence. The deviations always sum to exactly zero, for any dataset, because the mean is the balancing point. The negatives below the mean perfectly cancel the positives above it. So the plain average of the deviations is always zero and tells you nothing about spread. We need a way to stop the cancellation.

Key terms

Deviation
How far a single value sits from the mean, which can be positive or negative.
Variance
The average of the squared deviations from the mean. A measure of spread.
Squared deviation
A deviation multiplied by itself, which makes it positive and grows fast for large deviations.
Squared units
The awkward units variance ends up in, such as percent squared, fixed by the standard deviation next lesson.

Why we square the deviations

The fix is to square each deviation before averaging. Squaring does two important jobs at once. First, it makes every deviation positive, since a negative times a negative is positive, so the below-mean and above-mean distances no longer cancel. Second, it penalizes large deviations far more than small ones. A deviation of 3 becomes 9, but a deviation of 6 becomes 36, four times as much even though the distance only doubled. This matches how we think about risk, because a value very far from the mean is more alarming than one slightly off. Variance is the average of these squared deviations, and it is finally a number that grows with spread instead of always collapsing to zero.

The formula in symbols

Formula
Variance = Σ(x − mean)² / N
  • Σ = add up over all the values
  • x = each value
  • mean = the average of the values
  • N = number of values

In plain words: take each value, subtract the mean, square the result, add up all those squares, and divide by the number of values. The worked example below walks through those exact steps with real numbers.

Worked example

Calculating a variance step by step

Find the variance of the numbers 2, 4, 6, and 8.

  1. Find the mean. 2 plus 4 plus 6 plus 8 is 20, divided by 4 is a mean of 5.
  2. Find each deviation. Negative 3, negative 1, 1, and 3.
  3. Square each deviation. 9, 1, 1, and 9.
  4. Average the squared deviations. 9 plus 1 plus 1 plus 9 is 20, divided by 4 is 5.
Result: The variance is 5.

Why it matters: Variance is just the average squared distance from the mean. The squaring stops the deviations from canceling and makes big deviations count for a lot more.

Calculation

Calculate a variance

Find the variance of the numbers 1, 4, and 7. (Their mean is 4.) Average the squared deviations, dividing by the 3 values.

Need a hint?

The deviations are negative 3, 0, and 3. Square them, add, and divide by 3.

Variance: why square?

A short, focused answer to exactly why variance squares the differences: it stops cancellation and penalizes big outliers. Watch it to lock in the key idea of this lesson.

The drawback of squared units

Squaring solves the cancellation problem but creates a new inconvenience. Because we squared the deviations, the variance is in squared units. If your returns are in percent, the variance is in percent squared, which nobody can interpret intuitively. What does 5 percent squared even feel like? This awkwardness is exactly why the next lesson introduces the standard deviation, which simply takes the square root of the variance to bring the measure back to normal units. Variance and standard deviation are two views of the same idea of spread, one in squared units and one in the original units.

Decision scenario

Why not just average the raw deviations?

A student suggests measuring spread by simply averaging the deviations from the mean, without squaring them. Why does this fail?

Variance in finance

In finance, variance measures how spread out an asset's returns are around their average, which is the raw statistical definition of risk. A stock whose returns cluster tightly around the mean has low variance and feels steady. A stock whose returns swing far above and below the mean has high variance and feels risky. Variance is also the quantity that combines across assets when you build a portfolio, which is why the portfolio variance lesson later in this unit depends directly on it. For now, the key is that variance is the average squared distance from the mean, and squaring is what makes it work.

Reflection

Explain the squaring

In your own words, explain the two reasons variance squares the deviations from the mean. Why is each reason useful for measuring risk?

Write an answer before comparing it with the model response.

Variance measures spread, but in awkward squared units. The next lesson takes its square root to get the standard deviation, the measure of spread in normal units and the number finance calls volatility.

Quiz

This lesson ends with a 5-question quiz. Create a free account or sign in to take it, save your progress and earn points.