edgekit

Joint distributions & correlation

One random variable describes a coin; markets are thousands of coins flipped together, and everything that matters — diversification, hedging, factor exposure, contagion — lives in how they co-move. This chapter builds the machinery of joint behaviour: joint and conditional densities, convolution, covariance and its Cauchy–Schwarz bound, the bivariate normal whose conditional mean is the regression line, and conditional expectation as the provably best predictor, with the tower property and the law of total variance as its calculus.

Intuition — the joint distribution is where portfolios live

Marginals are the biographies of individual assets; the joint distribution is the story of the whole market. Two portfolios can hold assets with identicalmarginal distributions and have wildly different risk: if the pieces move together, the diversification you thought you bought does not exist. Every question of the form “what should I expect for Y, having seen X?” — the primal question of forecasting — is a question about a conditional distribution. And the single most-used regression in finance, beta against the market, will fall out of this chapter as a two-line consequence of the bivariate normal.

Joint, marginal, conditional#

For two discrete variables the joint pmf is ; for continuous variables the joint density assigns probability to a region . Marginals come from summing or integrating the partner out, and conditionals from dividing:

The conditional density is a genuine density in for each fixed — renormalised by the marginal so it integrates to one. Independence is the special case where conditioning changes nothing, which is equivalent to factorisation:

Worked example. A two-asset market has joint pmf for (stock up/down, bond up/down):

Bond upBond downMarginal (stock)
Stock up0.150.350.50
Stock down0.300.200.50
Marginal (bond)0.450.551.00

Marginally, stock and bond are near coin-flips. But versus the unconditional 0.45 — bonds rally when stocks fall. Independence fails because . This flight-to-quality asymmetry is exactly the information a joint distribution carries and marginals discard — and it is the entire basis of the 60/40 portfolio.

Convolution — the distribution of a sum#

If , the density of is the convolution: condition on , note requires , and integrate over the ways:

Derivation — sum of two uniforms is a triangle

Let independent. The integrand is 1 exactly when and , i.e. . The length of that interval is

— the triangular density peaking at 1. One convolution already begins the march toward the bell: corners smooth, mass concentrates in the middle. Convolve again (three uniforms) and you get piecewise parabolas hugging a normal — the CLT of LLN & the CLT visibly at work.

For normals, convolution is best done with MGFs (derived in the distribution zoo): independent and have MGF product , so the sum is . Means add; for independent variables, variances add. Correlation is precisely what breaks that second rule.

Covariance and correlation#

Covariance measures linear co-movement:

It is symmetric, bilinear (), equals the variance on the diagonal, and vanishes under independence (because factorises). The variance of a sum picks up a cross term:

Correlation is covariance made scale-free, , and it is trapped in by Cauchy–Schwarz:

Proof — Cauchy–Schwarz, hence |ρ| ≤ 1

For any random variables with finite second moments and any real ,

A quadratic in that never goes negative must have non-positive discriminant: , i.e. . Apply this to the centred variables , to get , hence . Equality holds iff for some — iff is an exact linear function of .

Zero correlation is not independence. The canonical counterexample: let and . Then by symmetry (odd moments of a symmetric law vanish), yet is a deterministic function of — maximal dependence, zero correlation. Correlation sees only the linear shadow of dependence. Markets exploit the gap: index returns and index volatility are nearly uncorrelated in sign yet fiercely dependent — the leverage effect that copulas exist to capture.

Scatter plots of paired data at several correlation levels, from strongly negative through zero to strongly positive
What correlation looks like in a scatter. But beware the converse: a symmetric U-shaped cloud has zero correlation and total dependence. The coefficient measures linear association only.

The bivariate normal#

The bivariate normal is the joint law of two Gaussians glued together with a single dependence parameter :

with , . Its contours are ellipses tilted by correlation, and its conditional distribution is the most important calculation in applied statistics:

Derivation — the conditional law, and the regression line falls out

Fix and view the exponent as a function of . Complete the square:

so, after dividing by the marginal of (which absorbs the piece), the conditional density of given is proportional to — again normal:

Read it slowly, because three classical facts are hiding in it. (1) The conditional mean is linear in with slope — the OLS regression coefficient of Regression & Gauss-Markov and the market beta of factor models, derived rather than assumed. (2) The conditional variance does not depend on — knowing removes exactly the fraction of the variance, which is why in simple regression. (3) Because the slope multiplies , extreme predicts a less extreme — regression to the mean, as a theorem.

Elliptical contours of a bivariate normal density with the conditional mean line drawn through them, flatter than the 45-degree axis of the ellipse
Bivariate normal contours with the regression line E[Y|X=x]. Note the line is flatter than the ellipse’s major axis — the geometric face of regression to the mean: best predictions shrink toward the mean by the factor rho.

Worked example. A stock and the index have annual returns that are bivariate normal with , , . Given the index falls 10%, the stock’s conditional distribution has mean and standard deviation . The slope is the stock’s beta; the residual 24% is its idiosyncratic risk.

A Gaussian privilege. For jointly normal variables, is the entire dependence structure — zero correlation implies full independence (the joint density factorises when ). For every other family, correlation is a one-number summary of something richer, and tail dependence can hide behind modest . Assuming Gaussian dependence for assets whose crashes are synchronised is the modelling error behind 2008’s copula disasters — see Copulas & dependence.

The multivariate normal generalises: it is defined by the property that every linear combination is univariate normal, with mean and variance . That last expression forces to be positive semi-definite: it is a variance, and variances cannot be negative — so for every by construction, which is why a “correlation matrix” you invent by hand can fail to correspond to any possible world (and why estimated covariance matrices need care). Portfolio variance is the special case , the vector of weights.

Conditional expectation — the best predictor#

is a random variable — a function of that answers “what is my best guess of once I see ?” And “best” is a theorem, not a slogan:

Proof — E[Y|X] minimises mean squared error

Let be any predictor and write . Decompose:

The cross term dies by conditioning: given , the factor is a constant and by definition of ; the tower property below then kills the unconditional expectation too. What remains is minimised by choosing , and the minimum MSE is the leftover . Every forecasting model — OLS, trees, neural networks — is an attempt to approximate this one object with finite data.

Proof — the tower property (discrete case)

Claim: . Expand the outer expectation over the values of :

where the inner step is the law of total probability from Axioms, conditioning & Bayes. Averaging your conditional forecasts over what you might observe returns your unconditional forecast — you cannot expect to change your expectation. (This “no free updates” principle becomes the martingale property in Martingales & optional stopping.)

Variance decomposes the same way — the law of total variance(“Adam & Eve”, Eve for E-V-E):

Derivation — Adam & Eve in three lines

Start from and hit each term with the tower property: (the conditional version of the same identity), and . Subtract:

Total risk = average within-scenario risk + between-scenariorisk. For a strategy whose P&L depends on a hidden regime, the second term is regime risk — invisible in any single regime’s backtest, and the reason regime detection matters.

A scatter of Y against X with the conditional mean curve overlaid, and vertical slices showing the conditional distribution of Y at several values of X
Conditional expectation as a curve through vertical slices: at each x, average the Y values in the slice. The curve minimises mean squared error among all functions of X; the scatter around it is E[Var(Y|X)], the irreducible noise.

A closing definition worth a mention: variables are exchangeable if their joint law is invariant under permutations — weaker than iid (exchangeable variables can be correlated, like draws without replacement) yet strong enough to power symmetry arguments: any of exchangeable variables is the maximum with probability exactly . De Finetti’s theorem says exchangeable sequences are mixtures of iid ones — the philosophical bedrock of Bayesian inference.

A seeded simulation verifies the two headline formulas — the bivariate-normal conditional law and Adam & Eve:

joint_checks.py
import numpy as np

rng = np.random.default_rng(11)
n = 500_000

# Bivariate normal: stock (12%, 30%), index (8%, 18%), rho = 0.6
mu_s, sig_s, mu_m, sig_m, rho = 0.12, 0.30, 0.08, 0.18, 0.6
z1, z2 = rng.standard_normal(n), rng.standard_normal(n)
m = mu_m + sig_m * z1                                   # index return
s = mu_s + sig_s * (rho * z1 + np.sqrt(1 - rho**2) * z2)  # stock return

# Conditional law given index ~ -10%: theory mean -6%, sd 24%
sl = (m > -0.105) & (m < -0.095)
print(s[sl].mean(), s[sl].std())        # ~ -0.060, ~0.240

# Adam & Eve: Var(S) = E[Var(S|M)] + Var(E[S|M])
within = (1 - rho**2) * sig_s**2        # 0.0576
between = (rho * sig_s / sig_m)**2 * sig_m**2  # beta^2 * Var(M) = 0.0324
print(s.var(), within + between)        # both ~0.0900 = 0.30^2
Quant lens — diversification is a statement about the joint distribution
For an equal-weight portfolio of assets, each with variance and pairwise correlation , the portfolio variance is . The idiosyncratic term dies at rate ; the correlated term never dies. Diversification eliminates only the independent part of risk, and its limit is set entirely by the average correlation — which is why portfolios that look diversified in calm markets (low ) concentrate violently in crises, when correlations lurch toward one. Risk budgets built off the joint distribution, not a stack of marginals, are the subject of Portfolio construction and Risk management.

Practice problems#

Problem 1 — E[X | X + Y]

are iid with finite mean. Find .

Solution. By symmetry (exchangeability), and have identical conditional laws given the sum, so . But linearity forces . Therefore

with no distribution needed — an answer you should be able to give in one breath. Generalisation: for iid terms, . The grinding alternative (write the joint density, condition, integrate) takes ten minutes and works only for named distributions; symmetry works for all of them.

Problem 2 — Correlation of X and X + Y

are iid with variance . Find .

Solution. Bilinearity: . The scales: , . So

The natural follow-up: with terms, . This is why a single asset correlates with an equal-weight basket containing it, and why an index component can look “highly correlated with the market” on no signal at all — a trap in naive alpha attribution.

Problem 3 — Sum of n dice, given the first

Roll five fair dice. The first shows a 6. What is the expected total of all five?

Solution. Independence means conditioning on the first die leaves the others untouched:

The point of the question is the contrast with Problem 1: conditioning on a component shifts the expectation additively, while conditioning on the sum redistributes it symmetrically. A sharper variant: given the total of five dice is 20, the expected first die is by exchangeability — same machinery, opposite direction. Confusing the two directions (conditioning on parts vs wholes) is the most common error in this problem family — the gambler’s fallacy is exactly the belief that components must compensate within a fixed-sum story that nobody promised.

Problem 4 — Joint law of the min and max of uniforms

are iid Unif(0,1). Find the joint density of , and .

Solution. Start from the joint CDF-style event: for , . Differentiate once in and once in (with a sign for the direction of the min event):

Marginally is Beta(, 1) with mean and is Beta(1, ) with mean , so the expected range is . Note min and max are positively correlated (a high min drags the max up) — independence would be the wrong instinct. The full order-statistics toolkit arrives in Order statistics & extremes.

Problem 5 — Variance of a correlated portfolio

Two assets have volatilities 20% and 30% with correlation 0.5. You hold weights 60/40. What is the portfolio volatility? What correlation would make a 50/50 portfolio of two 20%-vol assets completely riskless?

Solution. Apply :

so — barely above the safer asset’s 20%, despite 40% of the book in the 30%-vol asset: that is diversification quantified. For the second part, set — which requires : perfect negative correlation, i.e. an exact hedge. Cauchy–Schwarz says no joint distribution can do better, which is why a true riskless hedge requires a linear relationship — the deep reason derivatives are hedged with their underlyings and not with proxies.

Next: the conditional means computed above deserve to be first-class objects — as a random variable in its own right, with the tower rule, the projection picture, and the variance decomposition. Conditional expectation.