Part 1 · ProbabilityLesson 512 minQuant Bible §2.4–2.5
Joint distributions, covariance and correlation
How two random variables move together, what correlation can’t see, and the three-correlations puzzle.
Single random variables price single bets. Trading is mostly about pairs and portfolios: a stock and its hedge, a signal and next-day returns. For that you need to describe how two random things move together.
Joint and marginal distributions
Two variables have a joint distribution, pX,Y(x,y)=P(X=x,Y=y) in the discrete case, or a joint density with
To get back the distribution of one variable alone (its marginal), sum or integrate out the other: pX(x)=∑ypX,Y(x,y) and fX(x)=∫fX,Y(x,y)dy.
X and Y are independent exactly when the joint factorises: fX,Y(x,y)=fX(x)fY(y) for every x and y.
Covariance
Cov(X,Y)=E[(X−E[X])(Y−E[Y])]=E[XY]−E[X]E[Y].
“Expectation of the product minus the product of the expectations.” Positive when the two tend to be above their means together. Useful facts:
Cov(X,X)=Var(X).
It is bilinear: Cov(aX1+bX2,Y)=aCov(X1,Y)+bCov(X2,Y).
Independent ⇒ Cov=0. The converse is false.
Correlation
Covariance depends on units (dollars times shares). Correlation rescales it to [−1,1]:
ρ(X,Y)=Var(X)Var(Y)Cov(X,Y).
ρ=±1 means one variable is an exact linear function of the other. ρ=0 means no linear relationship, which is not the same as no relationship.
Figure 5.1The joint density as a landscape3D model
The bivariate normal density for two standardised variables. Slide ρ and the hill swings onto the diagonal; the marginal curves on the back walls never move. The dots on the floor are 400 draws, and the orange ring holds about 68% of them.
Figure 5.2Correlation scatterInteractive
Slide ρ and watch the cloud tilt; the orange line is the least-squares fit, whose slope is Cov(X, Y)/Var(X). Then pick “Y = X²”: Y is completely determined by X, yet the correlation is about zero. Three outliers show how fragile a sample correlation can be.
The three-correlations puzzle
Jane Street (reported). Corr(X, Y) = 0.9 and Corr(Y, Z) = 0.8. What are the tightest bounds on Corr(X, Z)?
Any valid correlation matrix is positive semidefinite: all its eigenvalues are non-negative, so its determinant (their product) is too. With c=Corr(X,Z),
In general c∈ρXYρYZ±(1−ρXY2)(1−ρYZ2). Geometrically (lesson 3), correlations are cosines of angles between arrows: X is 25.8° from Y and Z is 36.9° from Y, so the angle between X and Z is between 11.0° and 62.7°.
Figure 5.3Three-correlations boundInteractive
The curve is the determinant of the correlation matrix as a function of the unknown correlation. Only the green band, where it is non-negative, is achievable. Try your own values for the two known correlations.
In code
import numpy as npC = lambda c: np.array([[1, 0.9, c], [0.9, 1, 0.8], [c, 0.8, 1]])valid = [c for c in np.linspace(-1, 1, 20001) if np.linalg.eigvalsh(C(c)).min() >= -1e-12]print(round(min(valid), 3), round(max(valid), 3)) # 0.458 0.982# Dependent but uncorrelatedrng = np.random.default_rng(3)x = rng.standard_normal(100_000)y = x ** 2print(np.corrcoef(x, y)[0, 1]) # ≈ 0
Check yourself
X is uniform on [−1, 1] and Y = |X|. Which is true?
By symmetry E[XY]=E[X∣X∣]=0 and E[X]=0, so Cov=0. But knowing X tells you Y exactly, so they are far from independent.