1.3.8 · D1Probability & Statistics

Foundations — Expectation, variance, and standard deviation

2,416 words11 min readBack to topic

Before you can read the parent note, you need to own every squiggle it uses. Below is every symbol and idea, in build order — plain words first, then a picture, then why the topic can't live without it.


1. A random variable

Plain words: roll a die — the outcome is a dot pattern, but turns that into a number . The capital is the machine; a lowercase (or ) is one specific number it can spit out.

The picture: think of a bag of possible values, each ball a number.

Why the topic needs it: expectation and variance are questions about . Without a number-producing machine there is nothing to average or to measure the spread of. This is built in detail in 1.3.01-Randomvariables-and-probability-distributions.


2. Probability

Plain words: means "never," means "always," means "one time in six."

Figure — Expectation, variance, and standard deviation
Figure s01 — Bar chart of the six die values. Each value on the horizontal axis gets a bar whose height is its probability ; the six heights add to exactly .

Look at the figure: each value on the horizontal axis gets a bar whose height is its probability. Two ironclad rules — every bar height is , and all bar heights add up to exactly (something must happen).

Why the topic needs it: expectation weights each value by how likely it is. The weights ARE these probabilities.


3. The summation sign

Plain words: . The big Greek (sigma) is just a compact "+".

The picture: a conveyor belt — each item rolls past, you drop its value into a running total.

Why the topic needs it: expectation for a discrete variable is "add up each value times its chance," which is exactly a .


4. The weighted average — the heart of expectation

Figure — Expectation, variance, and standard deviation
Figure s02 — A seesaw with a block at each value; block size = probability. The single point where the plank balances is the expectation .

Look at the figure: it is a seesaw. Each value sits at its position on the plank; the size of the block at that position is its probability. The single point where the plank balances is the expectation . That is why people call it the "centre of mass."

Why this and not a plain average? Because outcomes are not equally likely in general. The probability is the correct weight — it is literally how often that value shows up in the long run.


5. The symbols , ,

Why so many names? History. Just recognise them as identical so no note can surprise you.


6. Deviation

Figure — Expectation, variance, and standard deviation
Figure s03 — Each die value has an arrow back to the mean line . Green arrows are positive deviations (value above mean), red arrows negative (value below).

Look at the figure: each value has an arrow back to the centre line . Arrows pointing right are positive deviations (green), arrows pointing left are negative (red).

Why the topic needs it: variance is about how far values sit from the centre — the deviation is exactly that distance, and we must handle both signs, which motivates the next idea.


7. Squaring — why square, not absolute value

We need a way to make every deviation count as "distance," ignoring direction. Two candidates:

  • Absolute value — throws away the minus sign.
  • Square — a squared number is always .

The topic squares. Why square and not absolute value? Two concrete reasons:

  1. Squaring is smooth everywhere — you can do calculus on it. Absolute value has a sharp corner at zero (not differentiable), which breaks later machinery like gradient descent.
  2. Squaring gives the clean algebra that makes hand-computation easy.

8. Square root and standard deviation

Plain words: if is a height in cm, then is in cm² — an awkward unit. The square root drags it back to plain cm, so you can say "typically about cm away from the mean."

Why the topic needs it: interpretability. Variance is the algebra-friendly number; standard deviation is the human-friendly number. Feature scaling (4.1.02-Feature-scaling-and-normalization) divides by precisely because it lives in real units.


9. The integral — expectation for continuous variables

The integral sign is just the from before, taken to the limit of infinitely many infinitely thin slivers:

Read the pieces: is the value, is the tiny probability of that value's sliver (a weight), and adds every "value its tiny chance" — exactly the weighted average from §4, now with a curve instead of bars.

The figure below shows the term-by-term translation between the discrete sum and the continuous integral — the same weighted-average idea, once with bars and once with a smooth curve.

Figure — Expectation, variance, and standard deviation
Figure s04 — Left: discrete bars, . Right: a smooth density curve, . Arrows link , , and .

Why the topic needs it: real ML features (weights, pixel intensities, times) are continuous. You must recognise as "the same weighted-average idea, now with a curve."


10. Constants and linearity

The picture: stretches the seesaw plank; slides it sideways without stretching.

Why the topic needs it: the property list (linearity, scaling, shift-invariance) is written entirely in terms of .


Prerequisite map

Random variable X

Probability P of each value

Summation sigma adds them

Expectation E of X centre

Deviation X minus mu

Square the deviation

Variance sigma squared spread

Standard deviation sigma same units

Integral for continuous X

Constants a b c

Linearity scaling shift rules

This map feeds directly into Expectation, variance, and standard deviation and onward to 1.3.09-Covariance-and-correlation, 1.3.12-Central-limit-theorem, and 3.2.04-Bias-variance-tradeoff.


Equipment checklist

Test yourself — cover the right side.

I can say what (capital) means vs (lowercase)
is the number-producing machine; is one specific value it can output.
I can state the two rules every probability set obeys
each , and all of them sum to exactly .
I can state the continuous twins of those rules
everywhere, and (total area is ).
I can read aloud in plain words
"each value times its chance, added over all values."
I know why expectation is a weighted (not plain) average
because outcomes are not equally likely — probability is the correct weight.
I can name three symbols for expectation
, , .
I can say what means inside an integral
the width of one infinitely thin sliver; is that sliver's area, i.e. its tiny probability.
I know what measures and why sign matters
signed distance from the centre; positives and negatives would cancel to zero.
I can give two reasons we square deviations instead of using absolute value
squaring is smooth/differentiable everywhere, and it gives the clean algebra.
I can write the computational variance identity
.
I know why standard deviation takes a square root
to return spread to the same units as the original data.
I can explain why variance is written
because , so squaring gives .
I can state the linearity of expectation
.
I can state the scale and shift rules for variance
and .
I know the condition for to exist
the absolute values times probabilities add to a finite total (absolute summability).