Variance
Variance is the expected squared deviation from the mean.
On this page 7 sections
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 and are equally likely, their mean is . The deviations are and . Both squared deviations are , so their weighted average is also .
The definition says exactly which operations to perform:
where . Find the center, subtract it from each value, square, weight, and add.
PMF: , . Mean . Find .
Show answer and explanation
Squared deviations: . Weighted sum: .
02Unequal probabilities still matter#
Let equal with probability and with probability . Its mean is . The squared deviations are and , whose contributions are and .
The rare value contributes more to the variance because its squared distance is much larger. Averaging and equally would discard the probability model. Subtracting the mean after squaring would also change the calculation.
A two-state model gives with probability 0.75 and otherwise. Mean . Find .
Show answer and explanation
Squared deviations: . Weighted sum: .
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.
PMF: , . Mean . A learner averages signed deviations and gets zero. Find the variance.
Show answer and explanation
Squared deviations: . Weighted sum: .
If every value increases by , the mean increases by 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.
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]Pishro-Nik, Introduction to Probability: Variance ↗www.probabilitycourse.com · Article
- [2]Dive into Deep Learning, §2.6 Probability and Statistics ↗d2l.ai · Article