Skip to content
Glacius
ProbabilityConcept reference

Variance

Variance is the expected squared deviation from the mean.

On this page 7 sections
  1. Overview
  2. Measure spread around the mean
  3. Unequal probabilities still matter
  4. What zero and units mean
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01Measure spread around the mean#

Two distributions can have the same mean and very different variability. Variance measures how far values lie from their own mean by averaging squared deviations using the model's probabilities.

If 11 and 55 are equally likely, their mean is 33. The deviations are −2-2 and 22. Both squared deviations are 44, so their weighted average is also 44.

Outcomes 1, 5 have probabilities 0.5, 0.5. The balance point is the mean 3. Below, widths are probabilities and heights are squared distances to the mean. The total weighted area is variance 4.Outcomes 1, 5 have probabilities 0.5, 0.5. The balance point is the mean 3. Below, widths are probabilities and heights are squared distances to the mean. The total weighted area is variance 4.
Figure 1Outcomes 1, 5 have probabilities 0.5, 0.5. The balance point is the mean 3. Below, widths are probabilities and heights are squared distances to the mean. The total weighted area is variance 4.
Link to this figure ↗Download SVGDownload PNG

The definition says exactly which operations to perform:

Var⁡(X)=∑xp(x)(x−μ)2\begin{gathered}\operatorname{Var}(X)\\=\sum_x p(x)(x-\mu)^2\end{gathered}

where μ=E[X]\mu=E[X]. Find the center, subtract it from each value, square, weight, and add.

Check your reasoning

PMF: p(0)=0.5p(0)=0.5, p(2)=0.5p(2)=0.5. Mean μ=1\mu=1. Find Var⁡(X)\operatorname{Var}(X).

Show answer and explanation
1

Squared deviations: 1,11, 1. Weighted sum: 0.5+0.5=10.5+0.5=1.

02Unequal probabilities still matter#

Let XX equal 00 with probability 0.750.75 and 44 with probability 0.250.25. Its mean is 11. The squared deviations are 11 and 99, whose contributions are 0.750.75 and 2.252.25.

0.75+2.25=3.0.75+2.25=3.

The rare value contributes more to the variance because its squared distance is much larger. Averaging 11 and 99 equally would discard the probability model. Subtracting the mean after squaring would also change the calculation.

Check your reasoning

A two-state model gives X=0X=0 with probability 0.75 and X=4X=4 otherwise. Mean μ=1\mu=1. Find Var⁡(X)\operatorname{Var}(X).

Show answer and explanation
3

Squared deviations: 1,91, 9. Weighted sum: 0.75+2.25=30.75+2.25=3.

03What zero and units mean#

Signed deviations average to zero: negative and positive deviations cancel. Squaring before averaging prevents that cancellation. A model concentrated entirely at one value has zero variance; every deviation is zero.

Check your reasoning

PMF: p(−3)=0.5p(-3)=0.5, p(3)=0.5p(3)=0.5. Mean μ=0\mu=0. A learner averages signed deviations and gets zero. Find the variance.

Show answer and explanation
9

Squared deviations: 9,99, 9. Weighted sum: 4.5+4.5=94.5+4.5=9.

If every value increases by 1010, the mean increases by 1010 too. Each deviation from the new mean stays the same, so variance is unchanged. If every deviation doubles, its square becomes four times as large.

Variance has squared units. If values measure seconds, variance measures seconds squared. This lesson uses a known probability model; estimating a population variance from a finite sample is a different task with a different justification.

For ML, this calculation describes the variability of quantities such as a sampled loss or gradient component. Its mean alone cannot tell you how much individual observations fluctuate.

Key takeaway

Center, square, then weight by probability; signed cancellation is not a measure of spread.

  • Compute variance as expected squared deviation from the mean.

Sources & further reading

  1. [1]
    Pishro-Nik, Introduction to Probability: Variance ↗www.probabilitycourse.com · Article
  2. [2]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Variance.” Math behind ML. /learn/p-variance