◈ quant roadmapPart 1 · Ch 11/45
Quantitative Finance — the Mathematics of Markets · chapter 11

11Random Variables, Expectation & Variance

Chapter 10 handed us one move, and it was a good one. A fact arrives, your world shrinks to where that fact held, and you rescale the survivors until they add to one again. Every answer we produced with it was a probability. Not one of them was an amount. That is the gap this chapter closes, because a probability on its own cannot be traded, hedged, budgeted for or lost. This page attaches a number to every outcome, and then builds the one tool that collapses all those numbers into a single honest summary. The tool is called expectation, written E[·], and here is the thing worth knowing before we start. It is not four separate tools. The mean is E[X], and the variance is that very same machine pointed at squared distance from the mean. The moment generating function of Chapter 12, the covariance of Chapter 18, and the risk-neutral price e^(−rT)·E^Q[payoff] of Chapter 27 are that identical machine, aimed somewhere else. Learn to point it once and the rest of the course stops being a list of formulas to hold in your head.

The first die can wait. Almost everything downstream in this course is waiting on a number rather than a probability, and one page supplies it. The panel below traces the roads that lead back here.

You are here — the seam where "how likely" becomes "how much"
PART 0 MODEL ESTIMATE LEARN PRICE ACT how likely → how much 10 last 11 you are here 16 18 26 27 31 what Ch 10 handed us — the die, told "it came up even" → faces {2, 4, 6} p = ⅓ p = ⅓ p = ⅓ Σ p = ⅓ + ⅓ + ⅓ = 1.000  ✓ legal three even faces, re-weighted to sum to 1 — probabilities.
☝ tap a blue chapter above — watch a gold road run home
the debt is always the same shape
Every chapter downstream runs on an amount — an expectation or a variance. None of them runs on a probability. Tap one to see its IOU.
what Ch 10 handed us was a set of weights:
weights that sum to 1 — still not one amount
What you're looking at — the machine (E[·]) arrives wanted, not announced
gold = this page. Every downstream node's road ends here; the seam is where "how likely" turns into "how much".
blue = the chapters that owe it — standard error, covariance, the drag, the price, VaR are all E[·] or variance aimed somewhere.
green = Ch 10's weights are legal (they sum to 1) — yet toggling to "how much" shows nothing here is yet an amount. That gap is Chapter 11.
Fig. 1. 1. That's the seam between the last chapter and this one. Chapter 10 taught us to re-weigh a world after news arrives — and every answer it produced was still a probability, never an amount. Tap any downstream chapter and a gold road runs home: standard error (Ch 16), covariance (Ch 18), the volatility drag (Ch 26), a price (Ch 27), VaR (Ch 31) — each is expectation or variance, aimed somewhere. None runs on probabilities alone. Toggle the die from "how likely" to "how much": the weights are legal, they sum to 1, and still nothing there is an amount. Closing that gap is the whole of Chapter 11.

Three of those roads are worth naming now. Chapter 16 measures how much an estimate wobbles, and wobble is variance wearing a different coat. Chapter 26 explains why a volatile asset grows slower than its own average return, and that whole argument is one inequality we prove at the end of this page. Chapter 27 prices an option as a discounted expected payoff, which is E[·] pointed at a contract.

01The rule that pins a number to every outcome

Here is a bet, and it is deliberately small enough to hold in your head. We roll one fair die, and if it lands on 1, 2 or 3 you pay me £2. If it lands on 4 or 5 I pay you £1. If it lands on a 6 I pay you £6.

Nothing about the die has changed since Chapter 9. The sample space is still Ω = {1,2,3,4,5,6} and each face still carries weight 1/6. What is new is the table taped beside it, turning each face into a pound figure. That table is the entire idea of this section.

The payoff machine — X is the rule (the arrows), X(ω) is the number it returns
Ω — the die the six arrows are the rule X ℝ payoffs the rule never varies → ↑ randomness lives here X(·) = ?
Predict — is X a number?
↕ drag a gold arrowhead to edit the rule — the 1/6 weights won't move
answer the predict to wake the machine
What you're looking at — a function Ω, split from the number it returns
blue = the six die faces, the outcomes Ω — the only place chance lives
gold = the arrows are X (the whole rule) and the number X(ω) it returns
cyan = the token — the one face that landed, travelling to its value
red = the trap: "X is a number." It isn't — only X(ω) is.

X is not the algebra unknown you've solved for since school. X is the whole payoff rule; X(4) is one number it hands back (+1), and nothing about X varies. The randomness sits upstream — in which face lands. Edit the arrows and X changes; the die's 1/6 weights don't budge.

Fig. 2. Meet X where it lives: a rule that carries every outcome of Chapter 9's die (left, Ω, each face weighted 1/6) to a payoff on the real line (right). First predict whether X is a number — then roll, and the readout prints the function call X(4) = +1. Drag an arrowhead to re-point the rule and watch the 1/6 weights refuse to move; hit freeze to see that once the face is known, the table holds no chance at all. X never varies — the randomness is upstream, in which face lands.

Call the table X. It takes an outcome and returns a number, which makes it a function from Ω into the real numbers, and we call it a random variable. Now for the question that trips almost everyone, and I want you to answer it before reading on. Is X a number?

It is not. X is the whole rule, the entire two-column table, and it never changes while we play. X(6) is a number, and that number is +6. The name is genuinely misleading, because the word variable makes you picture the algebra unknown you have been solving for since school. There is nothing here to solve for.

So where has the randomness gone? It sits upstream of the table entirely, in the question of which outcome ω actually occurs. Once the die stops rolling, the table is a plain deterministic lookup with no chance left in it at all. That split is worth holding onto, because it is what lets us do everything else in this chapter.

One piece of notation falls straight out of the table, and it will do real work later. Write {X = x} for the set of outcomes the rule sends to the value x. It is not an equation waiting to be solved. It is a collection of faces, and collections of outcomes are exactly the events Chapter 9 taught us to weigh.

The preimage collector — pick a value and watch {X = x} reveal itself as a plain set of faces, with an ordinary weight.
{X = −2} = {1, 2, 3} — an ordinary event Ω = six faces {X = −2} −2 0.5000 {X = +1} +1 0.3333 {X = +6} +6 0.1667 weight ledger — Ch 9 weight of the set p(−2) = 1/6 = 0.1667
tap a value ▸ collect the faces that map to it
This is an event — Chapter 9 already knows how to weigh it.
3 faces feed −2 → p = 0.5000
What you're looking at — {X = x} is not an equation to solve, it's the set of faces the rule sends to x
blue = the six faces, the sample space Ω from Chapter 9 — each carries weight 1/6
cyan = the map: an arrow ties each face to the value X writes on it
gold = the pen {X = x} and its weight p(x) — just the Ch 9 weight of that set
green = the three pens partition Ω, so their weights must sum to 1.0000
Fig. 3. The notation {X = x} looks like an equation you solve for x — it is not. X is a rule that writes a number on every face, and {X = x} is simply the set of faces it writes x on. Pick −2 and three faces — {1, 2, 3}collect into the pen; its probability is nothing new, just the Chapter 9 weight of that set: 1/6 + 1/6 + 1/6 = 0.5000. Hit PARTITION and all three pens appear at once: because every face lands in exactly one pen, the weights 0.5000 + 0.3333 + 0.1667 = 1.0000. The dead SOLVE FOR X button is the whole lesson in one gag — there is nothing to solve. {X = x} is an event, and you already know how to weigh an event.

Gather them and the bet's structure appears. Three faces feed the value −2, so {X = −2} = {1,2,3} and its probability is 0.5000. Two faces feed +1, giving 1/3. One face feeds +6, giving 1/6. Every event is a plain subset of Ω, and we already know how to weigh those.

02Forget the outcomes, keep the weights

Look at what we just produced: three values, three weights, and a die that now feels like scaffolding we could quietly take down. That instinct is correct, and it is the first real economy of the subject.

Collapse Ω → the pmf is the whole random variable
Ω — the sample space, 6 outcomes −2 1 6 0.5000 0.3333 0.1667 Σ = 1.0000
quiz the bars — what survived?
drag COLLAPSE, then quiz the bars
What you're looking at — the six faces of Ω folding into the three bars that are the random variable X.
value −2 (you pay $2) — 3 faces → 0.5000
value 1 (win $1) — 2 faces → 0.3333
value 6 (win $6) — 1 face → 0.1667
Σ = 1.0000 — the axioms force it
Re-label secretly rewires which faces carry which payoff (same 3·2·1 sizes) — collapse first and the bars never move. The labels were scaffolding; the pmf is what X is. Only P(prime) turns red: it asks about faces, not values, so it needs Ω back.
Fig. 4. Sort every outcome by the number it produces and the six faces fold into three bars. Drag COLLAPSE and watch them fly: at the far right the sample space Ω is gone and only the −2, 1 and 6 bars remain, heights 0.5000 / 0.3333 / 0.1667 summing to a green Σ = 1.0000. Now quiz the bars. P(you pay me), P(win $6) and P(X≥1) all read straight off them — but P(roll is prime) turns red and hauls Ω back, because primality is a fact about faces, not values. Hit Re-label: the payoffs move to entirely different faces, yet the bars don't budge a pixel. That is the whole point — once outcomes are sorted by their value, the faces carry no information the bars do not. The pmf is the whole random variable.

The list of values with their probabilities is called the probability mass function, written p(x) = P(X = x). For our bet it reads p(−2) = 1/2, p(1) = 1/3 and p(6) = 1/6. Those three add to exactly 1, and they have to, because every face of the die was sorted into precisely one of the three groups.

Here the pmf is honest in a way that is about to stop being true, because each bar is a probability. You can read 0.5000 straight off the first bar, and that really is the chance of paying me two pounds.

Now change the question to something continuous, like the closing price of a stock. It can land anywhere in a range, and a range holds uncountably many candidates. Ask for the probability that it closes at exactly £100.000000…, on the nose forever, and the honest answer is zero. There are too many candidates for any single one to hold a positive share of a fixed unit of weight.

That looks like it destroys the whole apparatus, and it would if probability had to live on points. It does not, because probability lives in area instead. Build a histogram, then shrink the bins and watch what survives and what dies.

The bin shrink — watch a bar's probability die while its height survives and climbs past 1
height ≤ 1 — this could still be a probability 1.0 2 = f(1) 0 0.5 x = 1 RIGHTMOST BAR · width w = 0.2500 probability = shaded AREA 0.4375 ↓ falls height = area ÷ width 1.7500 ↑ climbs 0.4375 ÷ 0.2500 = 1.7500 the link that ties them POINT x=0.70 → P(X = 0.70) = 0.0000 (no width ⇒ no area) SLAB dx=0.10 → f(x)·dx = 1.40 × 0.10 = 0.1400 (a sliver of area)
height 1.75 > 1 — a density, not a P
What you're looking at — one honest density, two numbers that pull apart
the density f(x)=2x — the height rides it, climbing toward f(1)=2
the rightmost bar — its probability is the AREA, and it dies as bins shrink
the 1.0 ceiling + lamp — a probability can never pass it, a density routinely does
the probe — a zero-width line has P=0; give it a width dx and the sliver has area f(x)·dx
Fig. 5. The fatal misreading is to read the curve's height f(x) as "the probability of x." Watch it break: slide BIN COUNT up and the rightmost bar's probability — its shaded area — dies, 0.4375 → 0.0975 → 0.0248, while its height (that same area divided by the ever-thinner width) survives and climbs, 1.75 → 1.95 → 1.9875, converging on f(1)=2. The lamp lights the instant a height passes 1.000 — a thing no probability may ever do. Then work the PROBE: a zero-width line always reads P(X=x)=0.0000, yet the same spot given a width dx holds a real sliver of area f(x)·dx. Probability lives in the area; the height only says how fast that area piles up.

Take the little triangular shape in that panel, whose curve is f(x) = 2x on the interval from 0 to 1. With four bins the rightmost bar covers [0.75, 1] and holds probability 0.4375, so its height is 0.4375 / 0.25 = 1.75. Now shrink to twenty bins. The rightmost bar holds only 0.0975, and its height has risen to 1.95.

That is the whole lesson, so let's say it plainly. Bar height is probability divided by width. Both the probability and the width are racing to zero, and their ratio settles on a finite curve. The probability of any single bar dies, and the height lives.

The curve it settles on is the probability density function, written f(x). It is probability per unit length, in the same sense that a material has mass per unit volume, and that is why it is called a density. Notice that the far right of our triangle reaches f(1) = 2, which is a density of two. If f were a probability that number would be flat nonsense, and this is the exact inch where continuous probability tears for most readers.

So burn in the replacement reading. f(x) is not the probability of x. The small quantity f(x)dx is a probability, because it is a height times a width, the area of a very thin slab. Probability is the area under the density, always, and never the height of it.

There is one more object to meet, and it is the one that never breaks. Define F(x) = P(X ≤ x) and call it the cumulative distribution function. It asks a question that makes sense for any random variable at all, discrete or continuous or a mixture of the two.

Drag the sweep line — the CDF is the one object that works for both
THE BET · discrete TRIANGLE · continuous pmf p(x) ½ -2 1 6 riser = p(x) CDF F(x)=P(X≤x) 0.5000 0.8333 1.0000 F = 0.0000 pdf f(x)=2x f = 0.000 0 1 CDF F(x)=P(X≤x) slope F′ = 0.000 CDF ✓ — a jump ½, no complaint F = 0.0000
drag → · watch F fill behind the line on both sides at once
slope = density — same digits
What you're looking at — the same idea, told twice, and one object that survives both
blue = the discrete bet — pmf on top, its CDF a staircase; each riser IS a p(x)
violet = the triangle density f(x)=2x — pdf on top, its CDF a smooth F(x)=x²
gold = F(x)=P(X≤x), the running total, and the numbers to watch
cyan = the one sweep line you drag; the CDF fills in behind it live

A pmf needs jumps, a pdf needs smoothness — so neither is universal. But F(x)=P(X≤x) is defined for both, and its jumps are the p(x) and its slope is the f(x) (read the two digits — they agree). Flip to mixture: half a point-mass, half a uniform — pmf and pdf both fail, and the CDF handles it without complaint.

Fig. 6. Two distributions, one truth. On the left a bet: lose $2 half the time, win $1 a third, win $6 a sixth — a pmf made of spikes. On the right a triangle density f(x)=2x — a smooth pdf with no spikes at all. A pmf needs jumps to exist; a pdf needs smoothness. Neither describes the other, so neither is universal. But drag the sweep line and the same object builds under both: F(x)=P(X≤x), the running total of all mass at or below the line. Its jumps are exactly the discrete p(x) (highlighted riser = its bar), and its slope is exactly the continuous f(x) — the two digits print the same because "the density is the rate the CDF climbs" is a fact you can now read off, not take on faith. Then hit mixture: half a point-mass at 0, half a uniform. The pmf can't hold the smear, the pdf can't hold the spike — both fail. The CDF just jumps ½ and ramps: the one object that always exists.

Drag the line across and watch F fill up behind it. On our discrete bet it climbs in steps, reaching 0.5000 at x = −2 and 0.8333 at x = 1 before topping out at 1. Each step's height is exactly the pmf bar underneath it. On the triangle, F(x) = x² rises smoothly, so F(0.75) = 0.5625, and its slope at any point is the density there.

One sentence covers it. The CDF accumulates the density, and the density is the rate at which the CDF climbs. Chapter 3's derivative and integral just walked into probability theory wearing new names.

03★ The balance point

We now have a distribution, which is a whole shape. Often you want to hand somebody a single number instead. Should you take this bet? That is a question about one figure, not about three bars.

The obvious move is to average the values, and the obvious move is wrong. Averaging −2, 1 and 6 gives 1.667, and that answer quietly assumes the three outcomes are equally likely. They are not, because paying me two pounds happens half the time while being counted as one case in three.

So weight each value by how often it actually happens. Multiply, then add:

E[X] = Σ x · p(x)

For the bet that is (−2)(1/2) + (1)(1/3) + (6)(1/6), which comes to −1 + 0.3333 + 1 = 0.3333. The bet is worth about thirty-three pence a roll to you. We call this number the expectation, or the mean, and we write it μ.

Now the trap in the name, and it catches nearly everybody once. Roll a plain fair die and compute E[X]. Every face carries 1/6, so the answer is (1+2+3+4+5+6)/6 = 3.5. Commit to what that means before you touch the panel.

The balance rail — why a fair die averages 3.5 yet can never roll it
tilt level fulcrum = 2.60 E[X] = 3.5000 no outcome at 2.60 drag the fulcrum ◄ ► the long-run reading — running average press Run ▶ E[X] the average settles onto E[X] — the law of large numbers (Ch 13 says how fast)
A fair die — what value do you expect?
Commit a guess, then drag the fulcrum to where the rail levels.
tilts left — not the balance point
What you're looking at — E[X] is a balance point, not a value to expect.
blue blocks = the probabilities; heavier block, more likely
the gold fulcrum sits at E[X]=Σx·p(x) — the rail levels only there
at that point there's often no outcome — a die can't roll 3.5
the long-run average drifts, then hugs E[X] (an arithmetic demo, not a live sim)
Fig. 7. Expectation is not a value to expect. Put a distribution's probabilities on a seesaw as weighted blocks and drag the gold fulcrum: the rail levels at exactly one place, E[X] = Σx·p(x) — a centre of mass, nothing more. For a fair die that point is 3.5, and the badge shows the punchline: no face sits there. Try The bet (balances at 0.3333) and Drag a bar (watch the mean chase the mass, so a long tail drags it off the middle). The lower panel is a browser-side arithmetic demo, not an executed simulation: the running average wanders early and hugs E[X] by n = 2000 — the law of large numbers, whose speed waits for Chapter 13.

A die can never roll 3.5, not rarely and not approximately but never. So "expected value" is a poor name for the thing it labels, because E[X] is not a value you should expect to see. Drag the bars around on that rail and the better picture appears. E[X] is where the weighted mass balances, exactly like a centre of mass on a seesaw.

There is a second reading, and it is the one that makes the number useful at a desk. Play the same game over and over and average what you actually win. Those running averages settle down on E[X], which is why a thirty-three pence edge per roll is worth having. Chapter 13 turns that observation into the law of large numbers and says precisely how fast the settling happens.

The weights carry more load than they look like they do. It is easy to nod at "weight by probability" without feeling how much it changes.

The unweighted lie — race two calculators on one prize, then push the odds to the edge
PLAIN AVERAGE each value × 1/k £500.00 the plain answer THE ERROR GAUGE ×500 plain ÷ honest £1000 pays 1 time in 1000 E[X] — WEIGHTED each value × p(x) £1.00 the honest answer
plain overstates — off by ×500
The plain average is not a simpler method — it is a different distribution's answer.
What you're looking at — the same prize, weighed two ways
plain average gives every distinct value the same weight 1/k — it silently assumes each outcome is equally likely
E[X] weights each value by its real p(x), so a rare huge prize barely counts — this is the honest number
the gauge = plain ÷ honest. On EQUAL it reads ×1 (the honest footnote); on the raffle it screams ×500
Fig. 8. Two calculators race on one distribution. LEFT takes the plain average — sum the distinct values, divide by how many; RIGHT computes E[X] — each value times its own p(x). Start on RAFFLE: a £1000 prize won one time in a thousand. The plain calculator insists on £500.00; the honest one returns £1.00; the gauge reads ×500. Drag rarity back toward p = 0.5 and the two answers walk together until they meet at ×1. THE BET shows the everyday version (£1.6667 vs £0.3333, ×5). EQUAL flattens the odds — and the gap collapses to ×1, because the plain average is the expectation of a distribution where every outcome happens to be equally likely. The weights were never decoration.

A raffle ticket pays £1000 with probability 0.001 and nothing otherwise. Average the two values and you get £500. Weight them properly and the ticket is worth 0.001 × 1000 = £1. Unweighted averaging is not slightly off here. It is wrong by a factor of five hundred, and every mispriced tail risk in finance is a version of that mistake.

04The same average, with a density

Our formula sums over a list of values. A continuous variable has no list, so the sum has nowhere to start. This is the moment most textbooks write an integral sign and move on, and it is worth slowing down instead.

Go back to the thin bars, and chop the range into slices of width dx, treating each slice as if it were a single discrete outcome. Its value is the x at that slice. Its weight is the probability that X lands inside the slice, which is the area of the slab, f(x)dx.

That gives us a genuine discrete weighted average over the slices, Σ x · f(x)dx, using nothing we have not already built. Now let the slices get thin.

Bins into the integral — every bar carries a value x and a weight f(x)·dx, and their sum is the same weighted average
EVERY BAR = value x × weight f(x)·dx (the bar's area) ▸ hover / tap a bar to read its contribution x·f(x)·dx 2 0 0 0.5 x = 1 f(x) = 2x area 0.120 x=0.30 discrete twin toggle ▸ to compare DISCRETE TWIN — a 3-outcome bet Σ x·p(x) = 2.30 p=.2 x=1 .20 p=.3 x=2 .60 p=.5 x=3 1.50 each bar: value × weight — the same shape as a density bar
BIN COUNT — cut the area into more, thinner bars
0.6600
Σ x·f(x)·dx  ·  target ⅔ = 0.6667
residual 0.0067
THE DICTIONARY — one idea, two notations
Σ a sum of thin bars
p(x) the weight f(x)·dx
5 bins → 0.6600, aiming at ⅔
What you're looking at — the sum that quietly becomes an integral, with the dx kept honest
each bar carries a value x (where it sits) and a weight f(x)·dx (its area) — that area is the bin's p(x)
the running total Σ x·f(x)·dx: 0.6600 → 0.6650 → 0.6666, heading for exactly ⅔
the residual to ⅔ shrinks as the bars thin — the ∫ is that Σ's Riemann limit
the discrete twin: Σ x·p(x) is the same formula — value × weight, summed — in another costume
Fig. 9. Here is where the integral comes from — and the proof that dx was never punctuation. The density is f(x)=2x on [0,1]; cut its area into midpoint bars and every bar carries two things: a value x (where it stands) and a weight f(x)·dx — its area, which is exactly that bin's p(x). Hover any bar to split it and watch its contribution x·f(x)·dx printed out. The running total Σ x·f(x)·dx reads 0.6600 at 5 bins, 0.6650 at 10, 0.6666 at 40, converging on exactly as the residual collapses — the ∫ is just this sum's Riemann limit, the one you already own from Chapter 3. The dictionary reads off the translation as you drive it: Σ ↔ ∫ and p(x) ↔ f(x)·dx. Flip on the discrete twin to see Σ x·p(x) sitting beside it in the same layout — one weighted average, one formula, two costumes.

Drive the bin slider on the triangle and watch the running total. Five bins give 0.6600, ten bins give 0.6650, and forty bins give 0.6666, closing in on the exact answer 2/3. That is Chapter 3's Riemann sum doing exactly the job it was built for, and in the limit we write it as an integral:

E[X] = ∫ x · f(x) dx

So the dx in that expression is not punctuation, and it is not there to tell you which letter to integrate. It is half the weight. Pair it with f(x) and you have the continuous stand-in for p(x), doing the identical job of saying how much this value counts.

Hold the two formulas side by side and notice how little actually changed. Sum becomes integral, and p(x) becomes f(x)dx. The idea underneath is untouched, and it is still one sentence: multiply each value by its weight and add up.

05★★ One machine, any function

Here is where the chapter turns, and everything downstream is a consequence of the next few paragraphs. In practice you almost never want the average of X itself. You want the average of some function of it.

An option pays max(S − K, 0), which is a bent function of the price. A risk report wants E[X²], because squares are how spread gets measured. A growth calculation wants E[e^X], because compounding is exponential. In every case the thing you care about is g(X) rather than X.

So take the smallest possible example and try it honestly. Let X be uniform on {−1, 0, 1, 2}, so each value carries weight 1/4. What is E[X²]?

Your instinct says to build the new variable first. Call it Y = X², work out what values Y takes and with what probabilities, and only then average. Squaring the four values gives 1, 0, 1, 4, so Y lands on 0 with probability 1/4, on 1 with probability 1/2, and on 4 with probability 1/4. Average that and you get 0(0.25) + 1(0.5) + 4(0.25) = 1.5.

That is correct, and it is also more work than it needed to be. Watch the shortcut.

LOTUS, executed — predict E[X²], then run the script and watch two routes land on one number
X ∈ {−1,0,1,2} each p(x) = ¼ Y: 0·¼ + 1·½ + 4·¼ E[Y] = ? ROUTE A · build Y = X² first (1 + 0 + 1 + 4) / 4 E[X²] = ? ROUTE B · LOTUS — weight x² by ¼, never build Y ✓ same predict E[X²] → then RUN ▶
$ python lotus.py
Your instinct — E[X²] for this X is… tap one, then RUN
pick your instinct to arm RUN
What you're looking at — one machine E[·], pointed at g, run two ways
the source: X uniform on {−1,0,1,2}, every outcome carrying weight p(x)=¼
Route A, the long way — first build Y=X²'s pmf {0:¼,1:½,4:¼}, then average → 1.5
Route B, LOTUS — weight x² by X's own ¼, Y never built → 1.5 (same number)
the trap: E[X]²=0.25 is not E[X²]=1.5 — the square of the mean ≠ the mean of the square
Fig. 10. Asked for E[X²] with X uniform on {−1,0,1,2}, the instinct is to first build the distribution of Y=X² — that's Route A: the values 1,0,1,4 collapse to Y∈{0,1,4} with weights ¼,½,¼, so E[Y]=0·¼+1·½+4·¼=1.5. LOTUS (Route B) skips that entirely — weight x² by X's own ¼: (1+0+1+4)/4=1.5. Same number, and the distribution of X² never had to exist. The script genuinely runs and its real stdout is shown verbatim: both routes print 1.5, the assert passes, and the same machine pointed at g(x)=x returns 0.5 (LOTUS contains the definition), at x+3 returns 3.5, at 2ˣ returns 1.875 — every g, both routes, agreeing. The keystone: on the event {X=x} the transformed value is g(x), so g(x) inherits exactly the weight p(x). And the trap the numbers expose — E[X]²=0.25E[X²]=1.5, a gap of 1.25: the square of the mean is not the mean of the square.

Skip Y entirely, and instead square each original value, weight it by X's own probability, and add: ((−1)² + 0² + 1² + 2²)/4 = 6/4 = 1.5. Same number, and the distribution of never had to be constructed at all. Written out in general, that shortcut is

E[g(X)] = Σ g(x) · p(x)  and  E[g(X)] = ∫ g(x) · f(x) dx

It carries a slightly rude name, the Law of the Unconscious Statistician, or LOTUS. The joke is that people use it without noticing they have skipped a step. We are not going to skip it, because the step is one honest line and it is the reason the whole thing is legal.

Here it is. On the event {X = x}, the transformed value g(X) is g(x). There is nothing left to be uncertain about. So whatever probability that event carried, g(x) now carries the same amount, and the weights transfer across unchanged. No new distribution is needed because no new randomness was introduced.

What we actually have is bigger than a computational trick. Set g(x) = x and LOTUS hands back E[X]. Set g(x) = x² and it hands back E[X²]. Expectation is one machine, written E[·], and the function you point it at is a free choice.

And one warning arrives free with the machine, so take it now. In our example E[X] = (−1+0+1+2)/4 = 0.5, so E[X]² = 0.25. But E[X²] = 1.5. Those are not close and they are not meant to be. The mean of the square is not the square of the mean. That gap will turn out to be the most useful quantity in the chapter.

There is a fair objection to LOTUS hiding in that very example, and it deserves an answer rather than a shrug. Squaring is not one-to-one, since both −1 and +1 land on the same output. When LOTUS lists them as two separate terms, is it double-counting something?

The collision audit — squaring sends −1 and +1 to the same place; run the script and watch LOTUS survive it
outcomes of X values of Y = g(X) −1 and +1 both land on Y=1 — isn't that double-counting?
$ python collision_audit.py
Audit the merge — pick a function g to send X through:
squaring collides −1 and +1 onto Y=1 — the classic objection
merged weights hidden — hit RUN to reveal
the assert is load-bearing: it checks the merged weight equals the LOTUS terms added
What you're looking at — the same weights, added at two different moments
an outcome of X and its weight p(x); a value of Y reached by just one x passes straight through
a collision: several x land on one Y, so the long route adds their weights → the merged weight to watch
the assert PASS: merged weight = the LOTUS contributions added — same sum, LOTUS just adds later
the objection — listing −1 and +1 separately looks like double-counting, until you see they add to the merge
Fig. 11. The sharpest objection to LOTUS: since g(x)=x² sends −1 and +1 to the same output, listing both as separate terms looks like double-counting. Pick a g and hit RUN: the script genuinely executes and its real stdout is shown verbatim. The three-column ledger prints each x, its weight p(x), and its contribution g(x)·p(x) — so −1 contributes 1·¼ and +1 contributes 1·¼, both listed separately. The long route's grouping step then prints the merge explicitly — Y=1 collects x=−1 and x=1 → weight 1/2 — and the load-bearing assert 1/2 == 1/4 + 1/4 → PASS actually runs. Same addition: the long route adds the colliding weights, and LOTUS adds the same two contributions inside its sum. The brutal collider x mod 2 collapses three outcomes onto each Y and both routes still land on 0.5; the injective control x+3 merges nothing and the two ledgers are line-for-line identical. Collisions are handled by addition either way — LOTUS just adds later.

It is not, and the audit shows why. The long route merges those two outcomes into the single value Y = 1 and adds their weights, giving 0.25 + 0.25 = 0.5. LOTUS keeps them apart and contributes 1²(0.25) + 1²(0.25), which is the same 0.5. Addition happened either way, and LOTUS simply does it inside the sum instead of beforehand.

06★ Linearity does not care about dependence

Point the machine at g(x) = ax + b and something very convenient falls out. Pull the constant a outside the sum and separate the b term, which is legal for any finite sum, and you land on E[aX + b] = a·E[X] + b. Scaling and shifting pass straight through expectation untouched.

The version that matters is the one for sums of two variables:

E[X + Y] = E[X] + E[Y]

Read that carefully, because there is no condition attached to it. No independence requirement, no mention of correlation, nothing about how X and Y were generated. It is true when the two are strangers and it is true when one is a strict function of the other.

Your gut will refuse this, and the refusal is understandable. Chapter 10 spent a whole page showing how much dependence changes, so surely it must change an average too. Here is the reason it cannot. Go outcome by outcome across the sample space and write the weighted sum of X + Y. Split it into the X part and the Y part. Nothing else happened there, so all you did was reorder a finite sum, and reordering never asks whether the terms know each other.

Three couplings, one mean — flip the joint table and watch E[X+Y] refuse to move
joint table  P(X=x, Y=y) X → Y 1 2 3 4 5 6 1 2 3 4 5 6 two independent dice every row & column sums the same → marginals unchanged: E[X]=E[Y]=3.5 the mass just moves — the totals don't stdout — genuinely executed ↓ CASE 1 · two independent dice E[X] = 3.5000 E[Y] = 3.5000 E[X]+E[Y] = 7.0000 E[X+Y] = 7.0000 (over all 36 cells) assert E[X+Y] == E[X]+E[Y] OK ✓ Var(X+Y) = 5.8333 E[XY] = 12.2500 E[X]*E[Y] = 12.2500 assert E[XY] == E[X]*E[Y] OK ✓ -> independent: products split too seed=42 · 10,000 random couplings max|E[X+Y]-(E[X]+E[Y])| = 0.0
# explicit JOINT tables — no independence
seed = 42
def E(P, f):        # expectation the HARD way
  return sum(f(x,y)*P[x][y]   # weight
             for x,y in cells)  # all 36
assert E(x+y) == E(x)+E(y)  # ALWAYS
try:
  assert E(x*y) == E(x)*E(y) # ?
except AssertionError:
  print('products do not split')
sums split ✓ products split ✓
tap a case → will the mean move? (it won't)
What you're looking at — the same run over three joint tables, and only one number ever moves
the joint table — where the two dice put their weight; the coupling, built by hand so no independence sneaks in
E[X+Y] = 7.0000 in all three — the mean only ever adds, so tangling the dice can't touch it
Var(X+Y) swings 5.83 · 11.67 · 0 — the spread feels the coupling completely
the caught FAIL: E[XY] ≠ E[X]·E[Y] unless independent — products don't split, only sums do
Fig. 12. Three joint tables on two dice, built by hand so nothing is assumed: independent, then Y = X, then Y = 7−X. For each, the script computes every expectation the hard way — iterating all 36 cells and weighting (x+y) — and all three print E[X+Y] = 7.0000. The dependence is unmistakably real: Var(X+Y) reads 5.8333, 11.6667, 0.0000, and the product check E[XY] == E[X]·E[Y] is caught failing the moment independence is gone (case 3: 9.3333 vs 12.2500). A final seed=42 sweep over 10,000 random couplings prints max|E[X+Y]−(E[X]+E[Y])| = 0.0. The mean only ever adds, and reordering a finite sum never asks whether the terms are related — so dependence cannot touch it. The spread is not so lucky.

That panel runs three couplings that could hardly be more different. The first is two independent dice, and the second is the same die counted twice, so Y = X and the two move in perfect lockstep. The third is Y = 7 − X, which is as perfectly opposed as two variables can get, since their sum is pinned at 7 forever. All three print E[X + Y] = 7.0000.

Their variances are 5.8333, 11.6667 and 0. So dependence is enormously important, and Chapter 18 is largely about measuring it. It simply has no grip on the mean, because the mean only ever adds. Spread multiplies terms together, and multiplication is exactly where the entanglement bites.

On its own the rule looks almost too plain to be a tool. It turns problems that appear to need a full joint distribution into a short sum of easy pieces.

Here is the classic. n people check their hats at a restaurant, and a careless attendant hands them back in a completely random order. How many people, on average, get their own hat back? Commit to an answer, and notice whether your answer depends on n.

The hat check, executed — predict whether the answer grows with n, then read the real stdout
python3 hatcheck.py — real stdout E[matches] 2 1 0 = 1, always ? grow? → 0? or 1?
Before it runs: as n grows 1→8, does E[matches]…
▶ pick one to run the code & reveal the real output
choose your prediction first
# block 1 — this loop actually ran ↓
from itertools import permutations
for n in range(1,9):
  fp = 0
  for p in permutations(range(n)):
    fp += sum(p[i]==i for i in range(n))
  print(n, fp/factorial(n))  # → 1.0
predict, then the real stdout appears
What you're looking at — one answer, reached three honest ways, and it never budges off 1
the gold dashed line at 1 — the expected number of correct hats, where every block lands
block 2: eight indicators, each worth , stacked — they sum to 1 with the joint distribution never built
block 3: a seeded Monte Carlo at n = 10³ and 10⁵ — the empirical mean sits on 1 too, and does not grow with n

That's linearity earning its keep. Write matches = I₁+…+Iₙ, take expectations one at a time — E[Iₖ] = 1/n each, n of them, sum = 1. The indicators are hopelessly tangled (if seven hats are right the eighth must be too) and it does not matter, because we only ever add them. No independence, no joint distribution, exactly 1 for every n.

Fig. 13. A genuinely executed CodeRun: the numbers on the left are the real stdout of a Python run, not a drawing of one. Block 1 enumerates every permutation for n = 1…8 (1, 2, 6, 24, 120, 720, 5040, 40320 of them — complete counts, not samples) and prints a column of exact 1.0. Block 2 writes the answer as a sum of indicators Iₖ, prints E[Iₖ] = 1/8 for each, and adds them to 1.0 — the joint distribution of the tangled indicators is never constructed. Block 3 is a seeded Monte Carlo (seed = 20260813) of 200,000 trials at n = 1,000 and n = 100,000: the empirical means land on 1.000 ± a tiny standard error, confirming the answer does not grow with n. The closing line reports the exact distribution of matches at n = 8, where P(0) = 0.3679 is already 1/e to four places — Chapter 15 explains that number.

The answer is 1, and not roughly one or one only once n gets large. It is exactly one, for two people and for two million. Here is the whole argument. Define I_k as 1 if person k gets their own hat and 0 otherwise, so the total number of matches is I_1 + I_2 + … + I_n. Each person is equally likely to receive any hat, so E[I_k] = 1/n. Add up n of those and the total is n × (1/n) = 1.

Look at what we never did. Those indicators are badly tangled, since person 1 receiving hat 3 changes the odds for everyone else. Working out their joint behaviour is genuinely hard. We did not need it, because we only ever added them, and addition is blind to dependence. That move has a name worth remembering: write the thing you want as a sum of indicators, then take expectations one at a time.

07Aim the machine at spread

Two investments both return 5% on average. The first returns between 4% and 6% every year without fail. The second returns 40% or loses 30%, roughly at random. The mean cannot tell them apart, and no sane person would treat them as the same instrument.

So we need a second number, one that says how far X typically wanders from μ. The natural first attempt is the plain average deviation, E[X − μ]. Try it on our bet before reading on, and guess what it gives.

Average the plain deviation and it is always exactly zero — watch why
length = x − μ · thickness = probability · area = weighted deviation $0 $3 $8 μ = 2.33 −1.1667 +0.2222 +0.9444 red total green total the pans match → dead level Σ p·(x − μ) 0.0000
red = green → dead level at 0.0000
the three areas ALWAYS sum to exactly 0
What you're looking at — the deviations cancel BY DESIGN
red = an outcome below the mean (negative deviation)
green = an outcome above it (positive deviation)
μ = the balance point, where red area = green area

Each bar's area is a weighted deviation p·(x−μ): −1.1667, +0.2222, +0.9444, adding to exactly 0.0000. Dragging the mass never breaks it — the mean just slides to the new balance point and the total snaps back. That cancellation is the definition of the mean, which is why the plain deviation cannot measure spread: the sign has to die first. |dev| kinks at 0; dev² stays smooth — the reason variance squares.

Fig. 14. A bet paying $0, $3, $8 with probabilities ½, ⅓, ⅙. Each bar runs from the mean μ to an outcome; its width is the probability, so its area is the weighted deviation. The reds and greens are engineered to cancel: −1.1667, +0.2222, +0.9444 = 0.0000. Drag the mass to try to break it — the mean just slides to the new balance point and the total snaps straight back. That perfect cancellation is exactly what makes μ the balance point, and exactly why the plain deviation is useless for spread. Kill the sign two ways: |dev| totals 2.3333 but has a non-differentiable kink at 0; dev² also lifts the reds up but stays smooth everywhere — the reason variance squares the deviation.

The three weighted deviations come out as −1.1667, +0.2222 and +0.9444, and they add to precisely 0. That is not bad luck with these particular numbers. Linearity says E[X − μ] = E[X] − μ, and μ is defined as E[X], so the answer is zero for every distribution that has a mean.

That failure is telling us something true. The positives and negatives cancel exactly, and that perfect cancellation is precisely what makes μ the balance point in the first place. Our measuring tool destroyed the very signal it was built to read, so the sign has to die before we average.

Two ways to kill a sign. Take the absolute value, or take the square. The absolute value is honest and people do use it, but it has a kink at zero and is not differentiable there. Squaring is smooth, which matters enormously once Chapter 8's calculus starts optimising these quantities. It also punishes one big miss far more than several small ones, which is usually what a risk manager wants.

So point the machine at squared distance from the mean, and give the result its name:

Var(X) = E[(X − μ)²]

Two bets, one mean of 0.3333 — build the squared-distance machine, then take its root and watch the tame twin's spread cross the wild one.
the bet ↑ the tame twin ↓ £ μ = 0.3333 2.7222 0.1481 5.3519 −2 +1 +6 side = |x − μ| · shade = p the honest nuisance → the repair 0 1 2 3 σ, in plain £
Same mean, two spreads. Hit to buy the units back, then drive the dial.
μ0.3333 — never moves
betVar 8.2222 £² · σ ?
twinVar 0.2222 £² · σ ?
nobody has ever been paid in pounds²
same μ = 0.3333 · spreads differ
What you're looking at — variance is a machine aimed at squared distance from the mean, and σ is the receipt that buys the units back.
the bet: −2, +1, +6. Each square's side is its distance from μ; its shade is its probability — so ink ≈ p·(x−μ)², summing to Var = 8.2222.
the tame twin: same μ = 0.3333, far tighter. Drive the dial and its σ climbs past the bet's — the mean never twitches.
μ & σ are the two honest numbers. √ turns the area (£²) into a length (£): σ = 2.8674 vs 0.4714.
£² is the nuisance — variance lives in pounds-squared, which is why finance quotes volatility (σ, in £), not variance.
Fig. 15. Two bets, one mean. Both distributions balance at μ = 0.3333, yet each outcome grows a square whose side is its distance from that mean and whose shade is its probability — so the ink you see is the weighted squared distance, piling up to Var = 8.2222 for the wild bet and just 0.2222 for the tame twin. But those totals live in pounds², and nobody is ever paid in pounds squared. Hit and the big area collapses to a plain length — σ = 2.8674 against σ = 0.4714 — the units bought back. Now drag the dial: it pushes the twin's mass outward while pinning the mean, and you can drive its σ clean past the bet's without the 0.3333 ever twitching. That gap the mean cannot see is exactly what variance measures, and the square root is why finance quotes volatility, not variance.

On our bet the three weighted squared deviations are 2.7222, 0.1481 and 5.3519, summing to 8.2222. Now a tamer bet with the identical mean of 0.3333, paying £1 a third of the time and nothing otherwise. Its variance is 0.2222. Same centre, wildly different behaviour, and at last a number that can see the difference.

One nuisance came along with the square, and it is not a small one. Our payoffs were in pounds, so the variance is in pounds squared. Nobody has ever been paid in pounds squared. Take the square root and you land back in the original units:

σ = √Var(X)

That is the standard deviation. For our bet it comes to √8.2222 = 2.8674 pounds, against 0.4714 pounds for the tame version. This is exactly why finance quotes volatility as a percentage rather than a percentage squared, and Chapter 16 will lean on that habit constantly.

08The identity you derive, not memorise

The definition works, but computing it is clumsy. You have to find μ first, then go back through every outcome subtracting it before you can square anything. Two passes. There is a cleaner route, and it is worth deriving rather than accepting.

Three honest lines — deriving Var(X) = E[X²] − E[X]², and why the order can never flip
X ∈ {−1, 0, 1, 2} · p = ¼ each μ = E[X] = 0.5 THE ALGEBRA THE NUMBERS · this X Var(X) = E[ (X − μ)² ] = E[ 2μX + μ² ] = E[X²] 2μ·E[X] + μ² = E[X²]2μ² + μ² = E[X²]μ² 2μ·E[X] becomes 2μ² and swallows one +μ²−μ² ORDER LOCK · variance is a mean of squares, so it can never be negative reach beat 4 to test the order
▸ step through the four honest lines
LINEARITY
BEAT 1 · Var(X) = E[(X−μ)²] — the mean squared distance from μ
mean squared distance = 1.25
flip the order — watch it break:
change the distribution:
What you're looking at — the identity built in four steps, never quoted
blue = the mean of the square, E[X²]
violet = the middle cross term that gets eaten
gold = the constant μ² (μ is the mean)
green = the answer — and it must stay ≥ 0
Fig. 16. The identity Var(X) = E[X²] − E[X]² reads like a conjuring trick, so build it and the trick disappears. Step through: start from the honest definition — variance is the mean squared distance from μ — expand the square to − 2μX + μ², take E[·] and pull the constants out (that is linearity, nothing more), then use E[X] = μ so the middle term becomes 2μ² and eats one copy of μ², landing on E[X²] − μ² = 1.25 — the very number the definition gave in line one. Now flip the ORDER LOCK to the wrong way round and it prints −1.25 with a red lamp: a variance can never be negative, so the mean of the square must be the bigger term — the order is fixed by a reason, not a mnemonic. Change the distribution to the bet and every line re-runs, landing on 8.3333 − 0.1111 = 8.2222.

Step through it and every line is something you already own. Expand the square algebraically: (X − μ)² = X² − 2μX + μ². Apply E[·] to all three terms, and pull the constants out using linearity, which is now available to us. That gives E[X²] − 2μ·E[X] + μ². Finally, E[X] just is μ, so the middle term becomes 2μ² and eats one copy of the last one:

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

In words, the mean of the square minus the square of the mean. Check it on the LOTUS example, where we already have both pieces: 1.5 − 0.25 = 1.25. Squaring the four deviations directly and averaging gives (2.25 + 0.25 + 0.25 + 2.25)/4 = 1.25 as well.

People flip the order of those two terms constantly, so here is the fix that never fails. Variance is an average of squares, so it can never be negative. The bigger term has to come first, which means E[X²] ≥ E[X]² always holds. If you ever write it the other way you will be claiming a negative variance, and the sign will tell on you immediately.

That inequality is more than a sign check. Earlier we found that E[X²] and E[X]² disagree, and now we know which one is larger, and by exactly how much. The gap between them is the variance. No coincidence, and the last section is about what it generalises to.

One honest footnote before we leave the identity. It is beautiful algebra and a slightly dangerous formula on a computer, because subtracting two large nearly-equal numbers destroys precision. Chapter 39 meets Welford's algorithm, which is how production risk systems actually compute a variance.

09★ Which way it leans

We know that E[g(X)] and g(E[X]) are generally different things, because averaging then transforming is not the same as transforming then averaging. What we have not answered is which of the two comes out bigger. The answer is more satisfying than it has any right to be.

Start with the case we already proved. For g(x) = x² we know E[X²] ≥ E[X]², because the difference is a variance. So for squaring, the average of the outputs sits above the output of the average. Squaring is the standard example of a convex function, and Chapter 3 drew convexity as a curve that bows upward with its chords lying above it.

Drag the two points, slide the weight, swap the curve — and watch the gap turn into the variance
g(x) = x² E[X] = 2 gap ← drag me → the gap, magnified locked = +1.00 gap 1.00 Var(X)
E[X]2.00
E[X]²4.00
E[X²]5.00
gap+1.00
Var(X)1.00
the gap IS Var(X) — locked at 1.00
What you're looking at — the chord's height above the curve, and why it equals a variance
blue curve g, and g(E[X]) — average the inputs first, then apply g (lands on the curve)
cyan chord, and E[g(X)] — apply g first, then average (lands on the chord)
gold gap = E[g(X)] − g(E[X]) ≥ 0 for convex g. For it equals Var(X) exactly — that's Jensen, and the gap is no mystery.
Fig. 17. Ask which is bigger, E[g(X)] or g(E[X]), and the gut has no anchor — so start from the one case already proved. Averaging the inputs then squaring gives 4; squaring then averaging gives 5; the gap of 1 is exactly Var(X), because E[X²] − E[X]² is the variance. Drag the points and the two numbers stay welded. That is Jensen: a chord of a convex curve rides above it, and the height it rides by is the cost of uncertainty. Slide the weight to a corner and the spread vanishes with the gap; switch to a straight line and the gap pins to 0.0000; switch to ln and the chord drops below, flipping the sign — ln(E[X]) = 0.6931 beats E[ln X] = 0.5493.

Drag the two points and the picture explains itself. Put X at 1 or 3 with equal weight. The average input is 2, so g(E[X]) = 4, which is a point on the curve. The average output is (1 + 9)/2 = 5, which is the midpoint of the chord. The chord sits above the curve, so 5 sits above 4, and the gap of 1 is precisely Var(X).

That is Jensen's inequality, and it holds for every convex function rather than just for squaring:

g convex ⇒ E[g(X)] ≥ g(E[X])

Flip the curvature and the inequality flips with it. For a concave function such as ln, the chord lies below the curve, so E[g(X)] ≤ g(E[X]). With the same two points, ln(E[X]) = ln 2 ≈ 0.6931 while E[ln X] = (0 + 1.0986)/2 ≈ 0.5493. Equality arrives only when the function is a straight line, or when X is a constant and there is no spread to bend.

So the whole rule is curvature, and nothing else. Convex bows up and the average of the outputs overshoots, while concave bows down and it undershoots instead. A straight line has no curvature at all, which is exactly why linearity was exact.

One volatility dial. The log return averages to 0 for every setting — yet the money it grows into averages above 1, and the excess tracks σ²/2. Curvature decides the direction.
LOG world · X = ±v MONEY world · e^X 0 +v −v balances at 0 E[X] = 0.0000 · for every v e^(·) the curve 1 1.22 0.82 e^(+v) e^(−v) E=1.0201 what a 0% average return promises: wealth stays at 1 ↓ hit COMPOUND — run the fair bet forward
Drag the dial → the log line refuses to move; the money average climbs.
e^(+v) 1.2214 · e^(−v) 0.8187
E[e^X] 1.0201 vs e^(E[X]) 1.0000
σ²/2 0.0200 ≈ excess +0.0201
Two-point X: σ²/2 is an approximation — close, not identical. Exact for a lognormal asset (Ch 26).
logs cancel to 0 · money averages 1.0201
What you're looking at — the same coin flip, read in two worlds. Logs average to nothing; money doesn't, and the gap is σ²/2.
the log world: the return is +v or −v, so its mean sits pinned at 0 — the flat line never twitches, however hard you drive the dial.
the money world: those same logs become growth factors e^(+v) and e^(−v). Averaging after the curve bends them lands above 1 — E[e^X] > e^(E[X]). That gap is the cost of uncertainty.
COMPOUND: a fair-looking bet, up v then down v, is ×(1+v)(1−v)=1−v² < 1. At v=0.2 that's 0.96 — the wealth line sags below the flat promise. That lag is the volatility drag, the seed of Ch 26's μ − σ²/2.
flip concave: swap e^x for a risk-averse (log-type) lens and the curvature — and the gap — reverse to −σ²/2. Same coin, opposite verdict: Ch 15 builds on this.
Fig. 18. One dial, two worlds. In the log world the return is +v or −v with equal chance, so its balance point E[X] = 0.0000 is welded to zero — drive the volatility as hard as you like and that flat line will not move. Feed the same two returns through the money curve and they become growth factors e^(+v) and e^(−v); because the curve bends, their average lands above the fair mark: at v = 0.2, e^(+0.2) = 1.2214 and e^(−0.2) = 0.8187 average to E[e^X] = 1.0201, while e^(E[X]) = 1.0000. That excess 0.0201 sits right beside σ²/2 = 0.0200 — close, not identical, because a two-point X is only an approximation (exact for a lognormal, Ch 26). Hit COMPOUND and the cost turns concrete: a fair-looking up-20%-then-down-20% bet is ×1.20×0.80 = 0.96, and the wealth line sags below the flat promise — the volatility drag that makes a jumpy asset lag its own average, the seed of Ch 26's μ − σ²/2. Flip concave and the whole gap reverses to −σ²/2: curvature decides the direction, every time.

Now the payoff, and it is the seed of an entire chapter. Suppose an asset's log return is +0.2 or −0.2 with equal chance, so the average log return is exactly 0. The actual growth factor is e^X, and e^x is convex, so Jensen guarantees a gap. Working it out, E[e^X] = (1.2214 + 0.8187)/2 ≈ 1.0201 against e^(E[X]) = 1.0000.

Read that gap slowly, because it is the shape of a real market fact. The arithmetic average return is above the compounded growth an investor actually experiences, and the gap widens with volatility. Here the excess is about 0.0201, and σ²/2 = 0.02 sits right beside it. Chapter 26 shows that for a lognormal asset the relationship is exact, and the correction μ − σ²/2 is the famous volatility drag.

The whole chapter in one object: E[·] is a single averaging machine — aim it at five different functions and out come the mean, the variance, covariance, the MGF and a price.
the running bet: −2 (½) +1 (⅓) +6 (⅙) → balances at μ = 0.3333 ① point me at a function of the outcome g(x) = x aim: the value itself ↳ same recipe every time: weight each g(x) by p(x), then add E[ · ] the averaging machine one machine, five aims → output dial THE MEAN 0.3333 on the bet, in £ chapters → ··· ··· YOU ARE HERE 11 mean · var 12 shapes 13 n grows 18 covary 27 price
▾ tap a function to aim the machine
MEAN → 0.3333 · Ch 11, here
What you're looking at — one averaging machine, E[·], aimed five ways. Learn the machine and the list stops being a list.
The machine E[·] never changes: weight every g(x) by p(x) and add. Only the function g you feed it does — that is what makes mean, variance, covariance, MGF and price one object, not five.
Take 1 — linearity: E[X+Y] = E[X]+E[Y] splits a sum without ever asking whether X and Y are independent.
Take 2 — E[X²] ≠ E[X]²: squaring re-weights the far outcomes, so those two numbers never coincide (that gap is the variance).
Take 3 — Jensen: a curved g always leans one way, so E[g(X)] and g(E[X]) pull apart — the cost of uncertainty.
Fig. 19. Here is the whole chapter as one object. In the middle sits a single machine, E[·] — and all it ever does is weight each value by its probability and add. Tap a function card and watch: feed it g(x) = x and the dial reads the mean, 0.3333; feed it g(x) = (x−μ)² and the same machine returns the variance, 8.2222. Feed it a product of two variables and you get covariance (Ch 18); feed it eᵗˣ and you get the moment generating function (Ch 12); feed it a discounted payoff and — under a different measure Q — you get a price (Ch 27). The recipe printed under the socket never changes; only the arrow's aim does. That is the payoff: mean, variance, covariance, the MGF and the risk-neutral price are not five formulas to memorise — they are one operator pointed five ways. Learn the machine and the list stops being a list. You are here at Ch 11; next come Ch 12 (a small family of shapes that keeps reappearing) and Ch 13 (what happens to an average as n grows).

So let's collect the chapter, because it really is one object. A random variable pins a number to every outcome. The distribution carries those numbers with their weights, as bars if the values are countable and as a density if they are not. Expectation is the probability-weighted average of whatever function of the outcome you choose.

Everything else on this page was that same machine, aimed somewhere new. Point E[·] at x and you get the mean. Point it at (x − μ)² and you get the variance. Point it at e^(tx) and Chapter 12 will call it the moment generating function. Point it at a discounted option payoff and Chapter 27 calls it a price.

Carry three things forward. Linearity lets you split a sum without ever asking how the pieces are related, and that is the sharpest tool on this page. E[X²] is never E[X]², and the gap between them has a name. And whenever a curved function stands between you and an average, check which way it bends before you trust the answer.

Next we stop inventing distributions one bet at a time. There is a small family of shapes that keeps reappearing, and they are related to each other by simple limits rather than by coincidence. Learn the root of that tree and the branches regenerate on demand.

iolinked.com
Written by Ajai Raj