Chapter 15 handed you something and refused to name it. Here is the name, and the whole chapter in one line. That leftover piece is covariance: the average, over the cloud, of a single signed product — how far X sits from its mean, times how far Y sits from its. Now the story behind it. You expanded the spread of a sum and out fell a third piece, E[(X−μx)(Y−μy)], that would not go away. You even saw what it was for. Two worlds, one with independent dice and one with Y = 7 − X welded to the first, had the exact same mean for their sum. Yet one sum sprawled and the other never moved. The mean was blind to the difference between them. The cross term was the thing that could see it. The signed product carries the direction in its sign. When X and Y rise together the product is positive. When one rises as the other falls it is negative. Its size, though, is drowned in whatever units you happened to measure in. So we divide the units out and get correlation, a clean number pinned between −1 and +1. One honest warning rides the whole way. Covariance and correlation see only the straight-line thread between two variables, and a curve can slip past both of them completely.
01The number we don't have yet
You already have a mean and a spread for every variable, one number per axis, and it is natural to think those two tell the whole story. They don't. Let me convince you there is a gap here, because it does not feel like one. The cleanest way to feel it is to look at data where the per-axis summaries are identical and the relationships are opposite. Same mean, same spread, and yet the two variables are doing completely different things.
Picture three scatterplots. In the first, taller people tend to weigh more, so the cloud leans up to the right. In the second, more hours gaming go with lower grades, so the cloud leans down. In the third, two unrelated measurements make a round blob that leans nowhere. Now here is the trap. I can arrange all three so their x-histogram is the same and their y-histogram is the same. Same mean on each axis. Same spread on each axis. Three different worlds, and the per-axis numbers cannot tell you which one you are looking at.
Three clouds, one frozen pair of marginals — swing the pairing
ρ = 0.85 — up-tilt, strong
What you're looking at — three joints sharing one frozen pair of marginals
gold dots = the joint pairing, which y-value rides with which x-value. Swing the control and this is the only thing that moves.
grey bars = the two marginal histograms, 4 points per bin in every one of the three pairings — the same rectangles, never redrawn.
Each axis has μ=0 and Var=5 (σ=√5≈2.24) no matter how the dots are paired. Only Cov(X,Y)=E[XY]−E[X]E[Y] changes: +4.25 (ρ=0.85) tilted up, 0 (ρ=0, exactly independent) shuffled into a blob, −4.25 (ρ=−0.85) tilted down. A mean and a spread per axis can't tell these apart — hit "hide dots" and try; co-movement lives only in the pairing, which a marginal throws away by construction.
Fig. 1. Sixteen points: four x-values and four y-values, four points on each, so every axis has μ=0 and Var=5 (σ=√5≈2.24) — fixed, forever. ① up-tilt pairs low x mostly with low y (Cov=4.25, ρ=0.85). ② blob pairs every x with every y equally often — the independent grid, Cov=0 exactly. ③ down-tilt mirrors up-tilt's y-side (Cov=−4.25, ρ=−0.85). Hit hide dots and try to tell the three apart from the bars alone — you can't, because the bars are the same four rectangles on every axis in all three; the relationship lives only in which dot sits with which, and a marginal was built to forget that.
Watch the two histograms sit still while the cloud swings from up-tilt to blob to down-tilt. The marginals — Chapter 14's word for the shadow each axis casts — cannot tell the three apart. So whatever distinguishes the three is not in either shadow. It lives in the pairing: which y got attached to which x. A marginal throws that pairing away. The pairing is exactly what we now need one number to capture.
So the goal is honest and small. We want a single number that scores how two variables move together. positive when they rise as one. negative when they trade off. Near zero when the cloud leans nowhere. That is the whole assignment. The rest of this chapter is us earning that number instead of being handed it.
02One point, one signed rectangle
Forget the whole cloud for a moment and zoom in on a single point. Draw two lines through the picture. A vertical one at μx, the mean of X. A horizontal one at μy, the mean of Y. Call the pair of lines the mean-cross. They split the plane into four quadrants, and the quadrant a point lands in says something precise about that point.
A point in the top-right has x above its mean and y above its mean. Both deviations — the signed distances (x − μx) and (y − μy) — come out positive. A point in the bottom-left has both of them negative. Those two are the "together" quadrants: the point sits on the same side of both means. The other two are the "trade-off" quadrants, where one deviation is positive and the other is negative.
Now the question the whole definition turns on. We want an operation that reads "same side of both means" as a positive number and "opposite sides" as a negative one. Same sign should give plus. Opposite sign should give minus. One ordinary operation already does exactly that. Multiplication. Two positives multiply to a positive, two negatives also to a positive, and a mixed pair to a negative. So the product (x − μx)(y − μy) is not a guess someone made. It is forced by what we asked for.
Drag the point through the mean-cross and watch the sign flip
jump to a quadrant
drag the dot, or use ←↑→↓
Why multiply, not add? — the rule the plane forces on us
the blue cross sits at (μx, μy) — the means, zero deviation, zero contribution
the gold dot is one point; its rectangle's sides are Δx=x−μx and Δy=y−μy
same side of both means → same sign → the product is positive → green
opposite sides → opposite sign → the product is negative — only × does this; + can't
Fig. 2. Zoom in on one point on the plane. Draw the mean-cross — dashed lines at μx and μy — and the point's two deviations, Δx=x−μx and Δy=y−μy, become the sides of a rectangle whose area is their product. Ask which single operation turns "same side of both means" into + and "opposite sides" into −: multiplication is the only clean answer, so the top-right and bottom-left quadrants fill green and the other two fill red — never a choice, always forced. Drag the point toward either mean line and one side of the rectangle collapses toward zero, taking the product with it. One signed rectangle is the exact quantity this chapter will next average, point by point, into Cov(X,Y).
Drag the point around and watch the signed rectangle. Its two sides are the deviations, and its area is their product. In the two together-quadrants the rectangle fills green, a positive contribution. In the two trade-off quadrants it fills red, a negative one. Slide the point back toward the cross and the rectangle shrinks to nothing, because a point sitting near either mean has almost no deviation to contribute. The sign of the co-movement is now something you can see, not a rule to memorize.
03Averaging the rectangles
One point gives one signed rectangle. A whole cloud gives a whole pile of them, some green, some red. The move now is the one that turned a squared deviation into variance last chapter: take the average over the distribution. That average is the number we have been chasing.
Here it is. Cov(X,Y) = E[(X − μx)(Y − μy)], the covariance of X and Y — the expected value of the signed product of their deviations. It says exactly what the picture showed. Average the green-and-red rectangles over the cloud, letting each point contribute in proportion to its probability. A point 2 above the mean in x and 3 above the mean in y contributes 2 × 3 = +6. Swap it to 3 below in y and it contributes 2 × (−3) = −6. If the cloud tilts up to the right, most of its mass lands in the two green quadrants, the positives win, and covariance comes out positive. Tilt the cloud down and the red quadrants fill, so covariance goes negative. A round blob spreads evenly across all four, the rectangles cancel, and covariance sits near zero.
Covariance = the average signed rectangle — the cloud's tilt is its sign
your call — will Cov be:
drag TILT — watch Cov cross 0
What you're looking at — every point carries a rectangle back to the mean-cross; Cov is their average.
green: point agrees with the cross (both above, or both below) → + area
red: point disagrees (one above, one below) → − area
Cov = average of all of them = E[(X−μₓ)(Y−μḷ)]
Tilt up ⇒ greens win ⇒ Cov > 0. Level ⇒ they cancel ⇒ exactly 0. Slide the cloud and nothing changes — every rectangle is measured from the mean-cross, which rides along.
Fig. 3. Drag TILT: the running Cov slides through exactly 0 at the level cloud and goes negative past it — because covariance is nothing but green rectangles minus red.
The slider summed the rectangles for you. Now do it once by hand, so the number stops being magic. Here are five points with their mean-cross drawn in. For each point, read off the two deviations, multiply them, and note the sign. Add the five products, divide by five, and you have built Cov yourself.
Do the covariance by hand — five points, five multiplications, no machine
before you click — the sum of five products will be:
pt
Δx
Δy
Δx·Δy
A
–
–
–
B
–
–
–
C
–
–
–
D
–
–
–
E
–
–
–
click all five points, then check your sum
drag E after you reveal — the total updates live here
What you're looking at — five points, one mean-cross, five multiplications you do yourself.
the dashed cross sits at (μx, μy) = (4, 4) — click a dot to read its own Δx and Δy off that cross
green: same side of both means → positive product
red: opposite sides → negative product
Cov = E[(X−μx)(Y−μy)] is nothing but these five signed products, averaged — you just did the arithmetic, by hand, on a cloud small enough to hold in your head.
Fig. 4. Predict the sign of the sum, then click A, B, C, D, E one at a time — each click reads off Δx and Δy against the cross at (μx,μy)=(4,4), signs the product green or red, and fills that row of the table. Add the five products, divide by five, type your answer, and press reveal to check yourself. Then drag E up through the μy line: its product flips from −6 (red) to +4 (green) and the running total swings from −1.60 to +0.40 — live, in front of you.
Two things are worth doing with your own hands here, and they land on one verdict: only the shape of the cloud matters, never where it sits. First, before you drag the tilt, predict the sign. The cloud leans up, so which colour wins? Then slide the tilt down through flat, and watch the running sum pass through exactly zero at the level cloud and go negative past it. The tilt is the sign — you are watching one become the other. Second, grab the whole cloud and slide it sideways, keeping its shape. Covariance does not move. That is not an accident. Every rectangle is measured from the mean-cross, and the cross rides along with the cloud, so no deviation changes. So only two things drive covariance. The tilt sets its sign. The tightness sets its size. Where the cloud sits is irrelevant.
Let me lock the "tilt is the sign" claim with a cleaner control than a hand-dragged cloud. Take a perfectly axis-aligned ellipse of points, wide one way and narrow the other, leaning nowhere. Its covariance is zero, because the ellipse is symmetric across both lines of the cross. Now rotate it.
Turn the dial — the cloud tilts and Cov(X,Y) moves, same instant
level → Cov = 0.00
What you're looking at — every dot casts a signed vote for Cov
blue outline — the ellipse holding all 48 (X,Y) points
green dot — (x−μx)(y−μy) > 0, votes Cov up
red dot — (x−μx)(y−μy) < 0, votes Cov down
violet cross — the eigen-axes PCA would find, unaided
Aha: you never touch Cov directly — turning the dial tips the colour balance, and the number is nothing but that vote, counted.
Fig. 5. At 0° the ellipse sits level and every green dot — where (x−μx)(y−μy) > 0 — is cancelled by an equal red one: Cov(X,Y) = 0.00 exactly, by symmetry, not by rounding. Drag the dial right and the cloud leans like "/" — green starts winning the vote and Cov climbs, peaking near +1.0 at 45°. Drag it left and the lean flips to "\" — Cov falls to about −1.0 at −45°. Switch eigen on and a violet cross locks onto the cloud's own long and short axes — the exact directions PCA would hand back, computed from nothing but these 48 points. The tilt and the number were never two facts to connect: rotating the ellipse produces both in the same motion, because Cov(X,Y) = E[(X−μx)(Y−μy)] just is the tilt, measured.
The lean of the cloud and the covariance number are the same thing wearing two costumes. Watch it happen. The moment the ellipse turns, two things arrive at the same instant: the cloud visibly leans, and the covariance readout lifts off zero. Rotate the other way and both flip negative together. They are not two facts you have to connect. They are one fact seen twice. That is the intuition to carry out of this section: covariance is the cloud's tilt, written as a number.
04Covariance is variance, reborn
Here is the quiet gift that makes covariance feel earned instead of invented. We just built a machine that takes two variables and averages the product of their deviations. Watch what happens when you feed that machine the same variable twice. Put Y = X into the definition and turn the crank.
A stepper: set Y = X in Cov(X,Y) and watch it collapse to Var(X)
Beat 1 / 5 · the definition
two separate factors, X's and Y's gaps
Beat 1. Cov(X,Y)=E[(X−μX)(Y−μY)]: multiply X's own gap from its mean by Y's own gap from its mean, then average the product.
What you're looking at — variance was hiding inside covariance the whole time
blue = X's own gap from its mean, (X−μX)
violet = Y's own gap — melts to blue once Y = X
gold = the answer, Var(X) — and the diagonal of the grid
Cov(X,X) = Var(X): a variable's covariance with itself is its variance — covariance was never a separate invention, variance is just its diagonal case.
Fig. 6. Set Y = X inside Cov(X,Y) = E[(X−μX)(Y−μY)] and the second factor stops being a different quantity: μY becomes μX because Y literally is X now, so (X−μX)(X−μX) is one factor multiplied by itself — a square. Its expectation lands exactly on the definition variance already had: E[(X−μX)²] = Var(X). Lay X and Y in a 2×2 grid and the pattern generalizes: the diagonal holds each variable's covariance with itself — its variance — while the off-diagonal holds their covariance with each other. Variance was never a separate invention; it's covariance meeting itself.
Here is the punchline before the algebra: variance was always a covariance. The second factor becomes the first, so Cov(X,X) = E[(X − μx)(X − μx)] = E[(X − μx)²]. That is Var(X), exactly the definition from last chapter. Variance is a variable's co-movement with itself. And covariance is the honest generalization: the identical machine, with the second slot freed to hold a different variable. Do not undervalue this as a relabel. It runs the other way round. Variance is the special case, the diagonal where the two variables coincide, and covariance is the general object that contains it.
Now let's cash this on the two worlds Chapter 15 left you holding. World A is two independent dice. World B is one die X with Y = 7 − X welded to it. Both worlds have identical shadows, so the mean of the sum is 7 in world A and 7 in world B. The mean genuinely cannot distinguish them. So ask covariance instead.
Toggle the two worlds — same mean, same marginals, opposite covariance
Cov(X,Y) = 0.000 — no tilt
click a world — the two combs never move
What you're looking at — the mean can't tell the worlds apart, covariance can
blue dots and combs = the dice, X and Y each uniform on 1–6 — the same in both worlds
green rectangle = a point on the SAME side of both means — a positive product
red rectangle = a point on OPPOSITE sides of the means — a negative product
That's the residue Ch 15 left with no name. World A's 36 points balance 18 green against 18 red — they cancel to Cov=0. World B's 6 points are ALL red, because Y=7−X forces X and Y to opposite sides of their means every time — nothing to cancel, so Cov=−35/12. Same mean-of-sum, same marginals, opposite tilt.
Fig. 7. Toggle the world: same dice, same E[X+Y]=7, same marginal combs — but World A's cloud fills a square (18 green rectangles cancel 18 red, Cov=0) while World B welds onto the falling line Y=7−X (all 6 rectangles red, Cov=−35/12≈−2.917). Preview: World B's correlation ρ comes out exactly −1.
In the independent world the cloud is a square blob, and its covariance reads 0. In the welded world every point lies on the falling line y = 7 − x, a perfect down-tilt, and its covariance reads −35/12 ≈ −2.917 — the same 35/12 that was one die's variance, now carrying a minus sign. That number is the residue Chapter 15 produced and would not name. It was never mysterious. It is the covariance, and you can read its sign straight off the tilt of the cloud. One caution about its size. That −2.917 is measured in pips squared, the units of the dice. When we divide those units out shortly, the welded world will turn out to sit at exactly −1, the most negative a correlation can be.
05The shortcut, and the one-way arrow
The definition is the meaning, but there is a second face you will actually compute with. It is the twin of last chapter's Var(X) = E[X²] − μ², and it comes out of the same move. Expand the product, then let linearity walk through it.
P(1,1) = 0.40 · indep at 0.25
Cov = E[(X−μx)(Y−μy)]
Independent ⇒ Cov=0, always. Cov=0 ⇒ independent is FALSE — next figure breaks it.
What you're looking at — the derivation, then the arrow it proves
X, Y — the two variables; the table is their live joint distribution
Cov(X,Y) = E[XY] − E[X]E[Y] — the computational form, updating live
TRUE: independent ⇒ Cov = 0 (step 5 proves it)
FALSE: Cov = 0 ⇒ independent (struck out at step 6)
Fig. 8. Expand (X−μx)(Y−μy) and take E[ ] term by term — μx, μy are constants, so they pull straight out of the expectation — and it collapses to Cov(X,Y) = E[XY] − E[X]E[Y], the exact twin of Var(X)=E[X²]−μ². Sub in independence and independent ⇒ Cov=0 falls out in one line — drag the table to 0.25 and watch Cov snap to exactly zero. But that arrow only runs one way: Cov=0 ⇒ independent is a separate claim, and it's false — struck out on the last step, proven wrong next figure.
Expand (X − μx)(Y − μy) into XY − μyX − μxY + μxμy and take the expectation of each piece. Here μx and μy are numbers, not random, so they slide out of the bracket just as μ did last chapter. The middle terms collapse and you are left with Cov(X,Y) = E[XY] − E[X]E[Y]. Check it on the welded dice: E[XY] = 9.333 and E[X]E[Y] = 3.5 × 3.5 = 12.25, so Cov = 9.333 − 12.25 = −2.917, the −35/12 from before. Now bring back one fact from Chapter 15. When X and Y are independent, E[XY] = E[X]E[Y]. Subtract, and the two pieces are equal, so Cov = 0. Independence forces the covariance to vanish.
Read that arrow carefully, because your gut is about to reverse it and it must not. What we proved is independent ⇒ Cov = 0. That arrow points one way only. The mirror claim, Cov = 0 ⇒ independent, is a different statement. And it is false. I am flagging it here, before you have seen why, because the false version installs itself the instant you look away. The next section is built to demolish it in your hands.
06What covariance is blind to
Here is the reversal the whole chapter exists to break, and it is the deepest counterintuition in the subject. Take Y = X², with X spread symmetrically around zero. Y is completely determined by X. Tell me X and I tell you Y exactly, with no slack at all. There is no stronger dependence than that. Before you read on, look at the U-shaped scatter and answer one question. Is the correlation positive, negative, or zero?
Guess the correlation of a U-shaped cloud, then watch its covariance snap to exactly 0
1 · your guess — the correlation is…
guess, then reveal — is it +, −, or 0?
What you're looking at — Y is exactly X², yet X and Y have zero covariance
the 5 equally-likely points — knowing X fixes Y=X² (total dependence)
signed rectangle (x−μX)(y−μY) positive
… and negative — each +x mirrors −x, so the two cancel
Cov = the average of them = 0: it measures straight-line trend, not “no relationship”
Fig. 9. Y = X² with X symmetric about 0: total dependence, zero covariance. Guess the correlation, then reveal it snaps to 0 — the mirror pairs (±x) share one y-deviation but flip the x-deviation, so their signed rectangles are equal-and-opposite and cancel. Cov = 0 measures “no straight-line trend”, not “no relationship”: that is why zero covariance is not independence.
Almost everyone says positive, or at least "strong". The answer is exactly zero. Now watch why. Overlay the mean-cross. The scatter is a U, mirror-symmetric across the vertical line. Take the point at x = +1 and its twin at x = −1. Squaring wipes out the sign, so both sit at the same height. They have opposite x-deviations but the same y-deviation. Put numbers on it: let X be −1, 0 or +1 with equal chance, so X averages 0 and Y averages 2/3. The right-hand twin contributes (+1) × (1 − 2/3) = +1/3, the left-hand twin (−1) × (1 − 2/3) = −1/3. Their signed rectangles are equal and opposite — one green, one red — and they cancel. Every point cancels with its mirror. The rectangles sum to zero.
So covariance did not measure "no relationship". It measured "no straight-line trend". And a U genuinely has none — it rises on the right exactly as much as it rises on the left, with no net tilt. That is the load-bearing limitation of this whole chapter, and now it is a fact you watched happen rather than a caution you were handed. Covariance is blind to any co-movement that is not a straight line.
And the U is not special. Any shape with a symmetric, tilt-free structure fools covariance in exactly the same way.
Cov = 0.00 — clearly dependent
green cancels red — a ring, a cross, even an arch can average to zero
What you're looking at — the blind spot, four ways
blue dots = the 8 data points in this shape
gold dot = the mean-cross, where μX meets μY
green rectangle = deviations agree in sign
red rectangle = deviations disagree in sign
The U-shape wasn't a special trick — any symmetric, tilt-free shape cancels its rectangles the same way. Covariance was never blind to dependence in general; it only ever had eyes for a straight-line tilt, which is exactly what the tilted blob finally gives it.
Fig. 10. Four shapes, one blind spot. A ring, a crossing ✕, and a symmetric arch each hide a real, obvious dependence — yet every green rectangle finds an equal red partner and Cov lands at 0.00. Only the tilted blob, whose deviations all agree in sign, survives averaging: Cov = 6.25. Covariance was never blind to dependence — it is blind to everything except a straight linear tilt.
Step through a ring, an X, a symmetric arch. Each one is strong dependence. Each one reads a covariance of zero, because for every green rectangle there is a mirror red one. One tool, one blind spot. Covariance and correlation see the linear thread of a relationship and nothing else. Keep that flag planted. It is the reason the last section of this chapter has to exist.
07The units lie — so divide them out
Covariance has the right sign, but its size lies, and it is worth breaking the number yourself to feel it. Measure a group of people's height in feet and compute the covariance of height with weight. Now measure the exact same people in inches. Not one person changed height. But every height number, and therefore every x-deviation, just got multiplied by 12.
Toggle feet ↔ inches on the SAME eight people — watch Cov leap 12×
x-axis unit
Cov = 5.49 ft·lb
ratio to feet: 1.00×
predict: does the cloud move? then flip the toggle — only the label and the number can.
What you're looking at — a relabel, not a remeasurement
the same 8 people, same dots — the toggle never moves one
Cov's units = X-units × Y-units, so it rides whatever X-unit you pick
feet→inches is ×12 on X alone — bilinearity says Cov scales by that same 12
Fig. 11. Same eight people, same cloud — the toggle only relabels the x-axis, feet as inches (×12, +0). Bilinearity says Cov(aX+b, cY+d) = ac·Cov(X,Y); here a=12 (height) and c=1 (weight untouched), so Cov leaps from 5.49 ft·lb to 65.89 in·lb — exactly ×12, with 0 of 8 dots moved. Covariance's units are X-units × Y-units, so its bare size can never mean "how strongly."
Toggle the units and watch the cloud sit perfectly still while the covariance readout jumps twelvefold. Say it read 40 in foot-pounds. The same people in inch-pounds give 40 × 12 = 480. A number that is supposed to say "how strongly" just changed by a factor of 12 for a pure relabel. That settles it. Covariance carries the units of X times the units of Y, so its raw magnitude means nothing on its own. You cannot say a covariance of 40 is "big" without asking, big in what units.
The fix is the oldest trick in physics: cancel the units by dividing. Covariance is measured in X-units times Y-units. The standard deviation σx is in X-units, σy in Y-units. So divide covariance by σxσy and the units cancel exactly. That pure number is the correlation, written ρ = Cov(X,Y) / (σxσy). Put some numbers in — invented ones, chosen to keep the arithmetic clean: covariance 40, height spread 0.5 feet, weight spread 100 pounds, so ρ = 40 / (0.5 × 100) = 0.8.
tap ft / in, or drag the slider →
Cov[ft·lb] ÷ σx[ft]σy[lb] = ρ[ ]
Cov 17 (×1) · ρ 0.99 pinned
Divide by σxσy and the units cancel — that's why ρ never moves
blue = the units — feet, inches, pounds — whichever you measured in
gold = Cov, σx, σy — each one carries those units, so Cov balloons right along with σx
green = ρ = Cov/(σxσy) — the units cancel exactly, so it never budges
Fig. 12. The same cloud, now with ρ = Cov(X,Y)/(σxσy) beside it. Toggle feet↔inches — or drag the rescale slider to any factor — and Cov jumps ×k while ρ sits pinned: σx scales by the same k and cancels it in the ratio.
Press the feet-to-inches toggle again with correlation on screen. Covariance balloons; ρ sits pinned. Here is why. Rescale X by 12 and covariance scales by 12, but σx also scales by 12, so the two twelves cancel in the ratio. In inches the spread is 6 and the covariance is 480, so 480 / (6 × 100) = 0.8, the very number the feet data gave. Correlation is scale-invariant. It does not care what units you chose, which is exactly the property covariance was missing.
There is a second way to read ρ that makes it click, and it reaches back to Chapter 13. Dividing each deviation by its own σ is exactly standardizing: turning X into Zx = (X − μx)/σx, the affine map that lands every variable at mean 0 and spread 1. Do that to both variables, and correlation is just the covariance of the standardized variables: ρ = E[ZxZy].
Press Standardize: the same signed-rectangle average becomes ρ
Predict: does the rectangles’ average still equal Cov once standardized?
avg signed area = Cov = 11.60
What you're looking at — the Ch 13 Z-map, applied to both axes at once
blue dot = one day's (temperature, ice-cream sales)
gold cross = the means — it slides to the origin once standardized
signed cross-products — their average is Cov, then ρ once axes are unit-free
Fig. 13. Five days of temperature and ice-cream sales, plotted raw. Press Standardize and both axes recenter at the mean and rescale to unit spread — the gold cross slides to the origin, and the same signed-rectangle average that read Cov = 11.60 now reads ρ = 0.88 directly. Flip °C/°F: the ruler relabels, the picture and ρ don't move.
Watch both axes get rescaled and recentered until the cloud sits on unit-free footing, the same footing for every problem. On those axes there are no feet, no inches and no pounds — just the bare shape of the relationship. Correlation is the covariance you read off after you have put both variables on that common footing. The mysterious denominator was never a fudge factor. It is the price of standardizing.
Now that ρ is a stable number, it is worth training your eye to read it off a picture. The strength of a correlation is the tightness of the cloud around its line. The sign of a correlation is the direction of the lean.
Drag ρ to tilt & tighten the cloud — or flip to guess ρ blind
drag — tilt & tighten the cloud
drag by lean, then reveal
ρ=+0.60 — loose & rising
What you're looking at — tightness is strength, lean is sign
blue dots = one sampled (X,Y) pair each
gold = the real regression line and ρ = Cov(X,Y)/(σ_Xσ_Y)
red = your guess-line, before the reveal
green verdict = a close guess
ρ is always between −1 and +1 and carries no units — squeeze the cloud onto one line and |ρ|→1; scramble it and ρ→0. It reads STRAIGHT-LINE lean only, so a curved pattern can score ρ≈0 while still being fully predictable — that trap is next.
Fig. 14. Sixty (X,Y) pairs, freshly sampled from Y=ρX+√(1−ρ²)·Z with X and Z independent, unit-variance draws — drag ρ from −1 to +1 and watch the blue cloud pivot and squeeze onto the gold regression line. The number on the gauge is the real Pearson correlation r=Cov(X,Y)/(σ_Xσ_Y), recomputed straight from these exact sixty points every time you move the slider — not assumed from the dial — and it always lands in [−1,1]. At ρ=±1 the noise term vanishes and Y becomes an exact linear function of X: a perfect line, by the theorem, not by luck. Flip to guess ρ: a fresh cloud appears at a hidden correlation, you set a red guess-line by lean alone, hit reveal to see the true gold line and score how close you were. Tightness reads off strength, lean reads off sign — that's the whole reason the number is worth having: it lets you compare relationships at a glance, without redrawing a single cloud.
You just learned to eyeball ρ from the whole cloud. But one stray point can forge that number. Start from a round blob correlating at nearly zero, then drag a single far-off point and watch ρ climb on its own. Nothing else in the cloud moved.
Drag the lone red point — watch ρ move while nothing else does
the outlier
drag the red point, or ←↑→↓
predict: top-right → ρ up or down?
Twenty points never move — one point does all the work
20 blue points, frozen forever — by themselves ρ = 0.00, always (a full grid, every x paired with every y)
1 red outlier — the only point you can move, anywhere on the plane
gold bar + ρ = the real Pearson r, recomputed on all 21 points every time you drag
Toggle remove it and the same twenty points snap ρ back to ~0.00 — proof the whole reading was one point's leverage, not the cloud's shape.
Fig. 15. Twenty blue points sit in a fixed 5×4 grid — every x-value paired with every y-value exactly once — so their correlation is 0.00 exactly, by construction, and none of them ever move again. One red point stands apart on a drag handle: before you touch it, predict what happens as you drag it into the top-right corner. Drag it there and ρ (recomputed live on all n=21 points) climbs to about +0.72; drag the same point to the bottom-right instead and ρ flips to about −0.72 — the twenty blue points never left their seats. Hit remove it and ρ snaps back to 0.00 on the remaining twenty, proving the reading was never the cloud's — it was one point's leverage the whole time. A ρ reported with no picture beside it can be a lie a single outlier told.
Drag ρ from −1 through 0 to +1 and watch the cloud change under it. At the bottom end it is a tight falling line. In the middle it is a shapeless blob. At the top end it is a tight rising line. Then flip it around: a fresh scatter appears, you guess its correlation, and the true value is revealed. After a few rounds you will feel 0.3 versus 0.8 in your gut. That intuition is the payoff — the number exists so you can compare relationships without redrawing them.
08The algebra of the cross term
One rung is missing before we can trust correlation's range, and it also pays a debt from last chapter. When you add two variables, do their variances simply add? Chapter 15 said "only when independent" and left the reason parked. Here is the reason. Apply the variance definition to the sum. Note that (X + Y) deviates from its mean by (X − μx) + (Y − μy), then square that.
Step 1/4 · the sum's deviation
S−μS = two deviations, added
What you're looking at — the cross term that Ch15 left unnamed
blue = Var(X), the diagonal cell — X's own squared deviation, averaged
green = Var(Y), the other diagonal cell — Y's own squared deviation
gold = the two off-diagonal cells, each Cov(X,Y) — together the 2·Cov(X,Y) term
Aha: that's why variances add only for independent variables — a cross-term of 2·Cov always rides along in the algebra, and independence is exactly the condition that sends it to zero. Covariance isn't a bonus fact; it's the correction the sum needed the whole time.
Fig. 16. Four steps rebuild Ch15's mystery cross-term from scratch. Step 1: S−μS splits into (X−μx)+(Y−μy), always true. Step 2: squaring gives a 2×2 area — two equal ab-rectangles are why the coefficient is exactly 2, not 1. Step 3: averaging every cell by linearity lands Var(X+Y)=Var(X)+Var(Y)+2·Cov(X,Y), the off-diagonal cells now named Cov(X,Y). Step 4: toggle the same two dice from Independent to Y=X and watch the gold cells collapse to nothing or fill flush — Cov flips 0.00→2.92, the total flips 5.83→11.67 (35/6 vs 35/3, matching Var(2X)=4Var(X)), and the check flips to a cross. "Variances add" was never a law — it's what's left when 2·Cov(X,Y) happens to be zero.
The algebra says the spread of a sum carries a 2Cov term. Now feel it. Slide the correlation from −1 to +1 and watch the pile of X + Y breathe. The pile is widest at the +1 end, where the two variables move together. It collapses to a single spike at the −1 end, where they perfectly cancel.
Slide the correlation — the pile of X+Y widens, then collapses to a spike
PREDICT — at ρ=−1 the pile of X+Y is…
= 2: no covariance term
What you're looking at — variance adds, and the correction is a real width
blue cloud — the paired points (X,Y), each with spread 1, tilting as ρ moves
cyan pile — the live distribution of the sum X+Y (height normalized to fill the panel)
gold bar — the actual Var(X+Y) = 2 + 2ρ
shaded gap — the 2·Cov correction (green when it adds width, red when it eats it)
Aha: the dashed mark at 2 is the spread you'd get if covariance were zero. The gold bar overshoots it for ρ>0 and falls short for ρ<0 — and that gap you can see growing and vanishing is the 2·Cov term.
Fig. 17. Both X and Y have spread 1, so the dashed mark sits at Var(X)+Var(Y) = 2 — the spread the sum would have if covariance were zero. Slide ρ and watch the gold bar leave that mark: at ρ=0 it lands exactly on 2 (2·Cov = 0.00), by ρ=+1 the cloud lies on the diagonal Y=X and the pile is widest at Var(X+Y) = 4.00 (2·Cov = +2.00, the whole green overshoot). Drag left and the correction turns red and eats width, until at ρ=−1 the pair welds to Y=−X, every sum equals the same number, and the pile collapses to one spike — Var(X+Y) = 0.00. That shaded gap you watched grow and vanish is the 2·Cov term in Var(X+Y) = Var(X)+Var(Y)+2·Cov(X,Y).
The square (a + b)² = a² + 2ab + b² gives three pieces. Take expectations term by term and you get Var(X + Y) = Var(X) + Var(Y) + 2·Cov(X,Y). There it is: the variances do not just add — a cross-term rides along, and it is twice the covariance. So Chapter 15 was right for one reason only. When X and Y are independent, the covariance is zero, the cross-term vanishes, and the variances add cleanly. When they move together, covariance is the exact correction that makes spreads combine. Run it on the welded dice: 35/12 + 35/12 + 2 × (−35/12) = 0, which is why that sum never moved off 7. That is the debt paid in full.
Now correlation's range falls out honestly, from a fact nobody argues with: a variance can never be negative. Standardize both variables, so each one has variance 1 and their covariance is ρ. Then look at Var(Zx − Zy), which must be ≥ 0.
drag → watch the cloud below collapse
standardize: Var=1, Cov(Zx,Zy)=ρ
What you're looking at — a variance that can't go negative pins ρ to [−1,1]
Zx, Zy are X and Y standardized: Var(Zx)=Var(Zy)=1, and Cov(Zx,Zy)=ρ.
Var(Zx−Zy)=2−2ρ≥0 gives ρ≤1; Var(Zx+Zy)=2+2ρ≥0 gives ρ≥−1 — a variance can never be negative.
Drag ρ toward ±1: the spread term shrinks to 0 and the standardized cloud collapses onto a line.
ρ=−1 is Chapter 15's welded world, Y=7−X — sitting exactly on the leash's floor.
Fig. 18. Standardize both variables so Var(Zx)=Var(Zy)=1 and Cov(Zx,Zy)=ρ. Step the proof: the cross-term rule on Var(Zx−Zy)=2−2ρ≥0 forces ρ≤1, and on Var(Zx+Zy)=2+2ρ≥0 forces ρ≥−1 — a variance can never be negative, so it leashes ρ to [−1,1]. Drag ρ and watch the standardized cloud below live: as |ρ|→1 the leftover spread shrinks to 0 and the points collapse onto a line. Pull it all the way to ρ=−1 and you land exactly on Chapter 15's welded world, Y=7−X.
The proof said ρ = ±1 means the points lie on an exact line. Now test that fence with your hands. Drag these points until the meter reads 1.000. You will find it locks only when every point sits on one straight line, and knocking a single point off drops ρ below the ceiling at once.
Drag six points — chase ρ = ±1, the fence you can only touch as a line
drag any point — try to push ρ to 1.000
ρ = +0.000
What you're looking at — ρ=±1 is a fence, not a big number
six gold points, freely draggable; the faint grey line is the best fit through wherever they sit.
line + dots turn cyan only when ρ rounds to exactly ±1.000 — a straight line, no exceptions.
snap locks a perfect line; drag any one point off it and ρ falls at once — Ch.15's leash proved ρ∈[−1,1], this is its floor and ceiling.
Fig. 19. Six points start as a loose blob (ρ = +0.460) with a faint best-fit line drawn through wherever they sit. Drag any point — the line pivots and ρ updates live to three decimals — and try to push it to 1.000. Press snap to line and all six lock onto a perfect line for the sign you picked: the line turns solid cyan, every dot turns cyan, and ρ reads exactly +1.000 (or −1.000 on falling). Now drag any one of those six off the line and ρ drops back below 1 immediately — there is no arrangement short of a straight line that reaches it. ρ=±1 is not "very strong correlation"; it is the exact edge Chapter 15's leash proved ρ can never pass, and you can only stand on it by making the cloud literally one line.
Turn the cross-term crank on it: Var(Zx − Zy) = 1 + 1 − 2ρ = 2 − 2ρ. That has to be at least zero, so ρ ≤ 1. Do the same on the sum, Var(Zx + Zy) = 2 + 2ρ ≥ 0, and you get ρ ≥ −1. So −1 ≤ ρ ≤ 1, always, proved in two lines. Nothing went in but the fact that a spread can never be negative. And the edges of that range mean something exact. If ρ = 1, then Var(Zx − Zy) = 0. Zero spread means no variation at all, so Zx − Zy is a constant. The standardized points then lie exactly on a line. That is what ±1 means: Y is a perfect linear function of X. It also closes the loop on Chapter 15's welded world, where Y = 7 − X is exactly linear. The covariance there was −2.917, a number in pips squared. The correlation there is −1, right on the floor, and that one carries no units at all. Correlation is co-movement measured as a fraction of the most a straight line allows: ±1 on the line, 0 for the tilt-free blob.
09The one place zero is safe
The whole chapter has drilled one warning: zero correlation is not independence. Now I owe you the single regime where it is. I want to be careful here, because after all that drilling this can feel like a betrayal. It isn't. It is a property of one special shape, not a reversal of the rule.
Take a jointly Gaussian pair — the tilted-ellipse bell from Chapter 14. Write out its density and look at where x and y actually touch each other. They are coupled in exactly one place: a single ρ·x·y cross-term buried in the exponent. Everything else in the formula is an x-part or a y-part, sitting apart. So watch what happens when you slide ρ to zero.
The Gaussian: where zero really means independent — drag ρ to 0 and watch the density factorize
drag → toward 0: the ellipse relaxes to a circle
tilted — X and Y move together
What you’re looking at — a jointly Gaussian bump, and the single knob that couples X and Y.
the contours of the joint density — their tilt is the correlation
the −2ρxy cross-term — the one place x and y touch in the exponent
at ρ=0 the exponent splits, eᵃ⁺ᵇ=eᵃeᵇ, so f = fₓ·fᵧ: independence
Y=X²: ρ=0 but X fixes Y — zero-correlation is safe only for a Gaussian
Fig. 20. Drag ρ to 0: the sole coupling — the linear −2ρxy cross-term — vanishes, the exponent separates into an x-part plus a y-part, and eᵃ⁺ᵇ=eᵃeᵇ factorizes the density into fₓ·fᵧ as the contours relax to a circle. The frozen Y=X² shows why that safety is Gaussian-only: correlation sees straight lines, never curves.
As ρ → 0, that lone cross-term disappears, and the exponent splits into an x-part plus a y-part. And a sum in an exponent is a product of exponentials — ea+b = ea·eb. Try it with a = 1 and b = 2: e to the 1 is 2.718, e to the 2 is 7.389, and their product 20.09 is e to the 3. So the joint density factorizes into fX(x)·fY(y), which is Chapter 14's exact definition of independence. You can watch the contours relax from a tilted ellipse to a perfect circle as it happens. For a Gaussian, and only in a case like this, zero correlation really does mean independent.
And there is a clean reason why the Gaussian is the exception. It has no curve for covariance to be blind to. The U-shape fooled covariance precisely because its dependence was nonlinear — a trend the straight-line ruler could not see. A Gaussian is a pure elliptical blob: all of its dependence is the linear tilt, with nothing hidden underneath. So once you kill the tilt, there is genuinely nothing left to miss. The exception and the rule are the same idea, read from two ends.
10What you carry out
Before the map, one honest check. Everything so far has been the average over a whole distribution. Real data is a finite pile of points, and the covariance you compute from it is a sample covariance — the same signed-product average, taken over the darts you actually have.
CodeRun — throw N darts, sum (x−x̄)(y−ȳ), no formula plugged in
sample 0.00 vs pop 0.00 cm²
What you're looking at — a real average, not a formula, standing in for Cov
each dart is a genuine (x,y) draw from the rotated generator — no formula decided its spot
the dashed ellipse is the population shape: Cov(θ) = (σᵤ²−σᵥ²)/2·sin2θ
the printed sign always matches the lean — the code was never told which way to tilt
Fig. 21. No formula is entered anywhere — the code sums (x−x̄)(y−ȳ)/(N−1) over N freshly-thrown darts and prints whatever falls out. The generator's two axes are independent with unequal spread (σᵤ=1.1 cm wide, σᵥ=0.45 cm narrow) — at θ=0° neither axis leans on the other, so the population covariance is exactly 0 and the sample statistic hovers near it even though the cloud is an oval, not a circle. Rotate the generating axes by θ and the population value becomes (σᵤ²−σᵥ²)/2·sin2θ — ≈0.39 cm² at 25°, climbing to its max ≈0.50 cm² at 45° — and the code's own signed-product average lands on that same number, same sign, on every run. Throw more darts and the sample number stops wandering: a real finite pile, summed with no formula plugged in, reproduces exactly the covariance the tilted ellipse promised.
This one runs real code, with no formula smuggled in. Scatter a few hundred darts from an oval generator, compute the sample covariance, and it lands near zero. Now rotate the generator so the cloud leans, recompute, and the number climbs off zero — with its sign matching the lean, exactly as the tilt picture promised. Sample and population tell the same story, which is the whole reason the theory is worth carrying.
So here is what you leave with, and it is smaller and stronger than a page of formulas. Covariance is the expected signed product of deviations. Its sign is the cloud's tilt. And it is literally variance with the second variable swapped in — Cov(X,X) = Var(X). Correlation is that same number with the units divided out, pinned into [−1, 1], hitting the edges exactly when the relationship is a perfect line. The welded dice show the pair side by side: a covariance of −2.917 in pips squared, and a correlation of −1 in no units at all. And the warning you will never drop: both of them read only the straight-line thread, so r = 0 does not mean independent unless the cloud is Gaussian.
Map so far — step or hover Ch 15→18: watch what Ch16's cross-term feeds forward
step the spine
tap a rung, or hover to preview →
hinge → Ch17, Ch18, Cov matrix
What you're looking at — the cross-term's three futures
the spine's other rungs — each chapter's own one-line result
Ch16, you are here — the chapter that named Cov(X,Y) and scaled it to ρ
a dashed thread — what the lit rung's result feeds forward
Cov matrix — covariance at scale: the machinery behind regression & PCA
Fig. 22. Ch15 built two numbers for one variable, μ and Var(X). Ch16 named what a single variable can't see — Cov(X,Y)=E[(X−μX)(Y−μY)] — and rescaled it unit-free as ρ=Cov(X,Y)/(σXσY)∈[−1,1]: exactly the term Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y) needed all along. Step or hover the spine and watch Ch16 fan out: to Ch17's tail bound (mean and variance alone, feeding the LLN), to Ch18's CLT (the spread of a sum — that same 2Cov(X,Y) sits inside the variance of any sum), and, generalised into a covariance matrix, to regression and PCA. That's why this chapter was inevitable — the cross-term it named is exactly what a sum's spread needs.
Look where that leaves the course. Chapter 15 built two numbers for one variable — where it balances and how far it sprawls. This chapter named the cross-term that appears the moment two variables are added, and gave it a clean, unit-free scale. That cross-term is not a curiosity. Chapter 17 bounds the tails of any distribution using nothing but a mean and a variance, and it proves the Law of Large Numbers the earlier chapters kept promising. Chapter 18's Central Limit Theorem asks about the spread of a sum, which you now know is unanswerable without the term you were handed here. And covariance at scale — a whole grid of them between many variables — is exactly the machine behind linear regression and principal component analysis. You are holding the seed of both.