Skip to content
LeetQuant
QR02 Advanced Probability and Stochastic Processes

QR02 · Advanced Probability and Stochastic Processes · Lesson 3 of 4

Multivariate and Conditional Distributions

Joint, marginal and conditional densities, the multivariate normal, and the formula for a Gaussian conditioned on another Gaussian, read as a regression.

18 min

Objective

Given a joint distribution, recover what one variable says about another: marginals, conditional densities, conditional means and variances. The centrepiece is the multivariate normal, where conditioning has a closed form that underlies regression, Kalman filters, Gaussian-process models and every "best guess from a noisy signal" interview question.

Joint, marginal, conditional

A joint density f(x,y)f(x, y) assigns probability to regions of the plane. The two operations you need:

  • Marginalise (forget a variable) by integrating it out: fX(x)=∫f(x,y) dyf_X(x) = \int f(x, y)\,dy.
  • Condition (fix a variable) by slicing and renormalising: fY∣X(y∣x)=f(x,y)fX(x)f_{Y \mid X}(y \mid x) = \dfrac{f(x, y)}{f_X(x)} wherever fX(x)>0f_X(x) > 0.

Intuition for conditioning: take the vertical slice of the joint density at X=xX = x. Its shape is the conditional distribution; dividing by fX(x)f_X(x) only rescales it to integrate to 1. Independence is the case where every slice has the same shape, i.e. f(x,y)=fX(x)fY(y)f(x, y) = f_X(x) f_Y(y).

Two identities let you avoid computing distributions you do not need:

E[Y]=E[E[Y∣X]],Var⁡(Y)=E[Var⁡(Y∣X)]+Var⁡(E[Y∣X]).\mathbb{E}[Y] = \mathbb{E}\big[\mathbb{E}[Y \mid X]\big], \qquad \operatorname{Var}(Y) = \mathbb{E}\big[\operatorname{Var}(Y \mid X)\big] + \operatorname{Var}\big(\mathbb{E}[Y \mid X]\big).

The second (the law of total variance) splits uncertainty into "noise left after seeing XX" plus "variation explained by XX".

Always track the support. Most errors in joint-density questions come from integrating over the wrong region, not from the algebra.

Worked example

a uniform point in a triangle

(X,Y)(X, Y) is uniform on the triangle 0<y<x<10 < y < x < 1. Find the marginals, the conditional distribution of YY given X=xX = x, and E[Y]\mathbb{E}[Y] and Var⁡(Y)\operatorname{Var}(Y) both directly and through conditioning.

Show solution

The triangle has area 12\tfrac12, so f(x,y)=2f(x, y) = 2 on it.

Marginals. For fixed xx, yy runs over (0,x)(0, x): fX(x)=∫0x2 dy=2xf_X(x) = \int_0^x 2\,dy = 2x. For fixed yy, xx runs over (y,1)(y, 1): fY(y)=2(1−y)f_Y(y) = 2(1 - y).

Conditional. fY∣X(y∣x)=2/(2x)=1/xf_{Y \mid X}(y \mid x) = 2 / (2x) = 1/x on (0,x)(0, x), so Y∣X=x∼Uniform(0,x)Y \mid X = x \sim \text{Uniform}(0, x), with E[Y∣X]=X/2\mathbb{E}[Y \mid X] = X/2 and Var⁡(Y∣X)=X2/12\operatorname{Var}(Y \mid X) = X^2/12.

Directly. E[Y]=∫012y(1−y) dy=13\mathbb{E}[Y] = \int_0^1 2y(1 - y)\,dy = \tfrac13, E[Y2]=∫012y2(1−y) dy=16\mathbb{E}[Y^2] = \int_0^1 2y^2(1 - y)\,dy = \tfrac16, so Var⁡(Y)=16−19=118\operatorname{Var}(Y) = \tfrac16 - \tfrac19 = \tfrac{1}{18}.

By conditioning. E[X]=∫2x2=23\mathbb{E}[X] = \int 2x^2 = \tfrac23 and E[X2]=∫2x3=12\mathbb{E}[X^2] = \int 2x^3 = \tfrac12, so Var⁡(X)=12−49=118\operatorname{Var}(X) = \tfrac12 - \tfrac49 = \tfrac{1}{18}. Then

E[Y]=12E[X]=13,Var⁡(Y)=E[X2]12+Var⁡(X)4=124+172=118.\mathbb{E}[Y] = \tfrac12\mathbb{E}[X] = \tfrac13, \qquad \operatorname{Var}(Y) = \frac{\mathbb{E}[X^2]}{12} + \frac{\operatorname{Var}(X)}{4} = \frac{1}{24} + \frac{1}{72} = \frac{1}{18}.

The two routes agree. The conditioning route is usually faster in interviews because the conditional distribution is often something you recognise.

The multivariate normal

The cleanest definition is constructive: X∈RnX \in \mathbb{R}^n is multivariate normal, X∼N(μ,Σ)X \sim N(\mu, \Sigma), if X=μ+AZX = \mu + AZ for a vector ZZ of i.i.d. standard normals and a matrix AA with AA⊤=ΣAA^\top = \Sigma. Equivalently, every linear combination a⊤Xa^\top X is univariate normal, with

a⊤X∼N(a⊤μ,  a⊤Σ a).a^\top X \sim N\big(a^\top\mu,\; a^\top \Sigma\, a\big).

When Σ\Sigma is invertible the density is

f(x)=1(2π)n/2 ∣Σ∣1/2exp⁡ ⁣(−12(x−μ)⊤Σ−1(x−μ)).f(x) = \frac{1}{(2\pi)^{n/2}\,|\Sigma|^{1/2}} \exp\!\Big(-\tfrac12 (x - \mu)^\top \Sigma^{-1} (x - \mu)\Big).

Consequences you should be able to state instantly:

  • Marginals of any subset are normal; read off the matching entries of μ\mu and the sub-block of Σ\Sigma.
  • Affine maps preserve normality: BX+c∼N(Bμ+c, BΣB⊤)BX + c \sim N(B\mu + c,\, B\Sigma B^\top). This is how you simulate one (take AA as the Cholesky factor) and how you decorrelate one.
  • Within a jointly normal vector, zero covariance means independence. This is the property that makes the conditioning formula below work.
  • Level sets of the density are ellipsoids (x−μ)⊤Σ−1(x−μ)=c(x - \mu)^\top\Sigma^{-1}(x - \mu) = c; the quadratic form is the squared Mahalanobis distance and has a χn2\chi^2_n distribution.

Conditioning one Gaussian block on another

Partition X=(X1,X2)X = (X_1, X_2) with

μ=(μ1μ2),Σ=(Σ11Σ12Σ21Σ22).\mu = \begin{pmatrix} \mu_1 \\ \mu_2 \end{pmatrix}, \qquad \Sigma = \begin{pmatrix} \Sigma_{11} & \Sigma_{12} \\ \Sigma_{21} & \Sigma_{22} \end{pmatrix}.

Then X1∣X2=x2X_1 \mid X_2 = x_2 is normal with

E[X1∣X2=x2]=μ1+Σ12Σ22−1(x2−μ2),Cov⁡(X1∣X2)=Σ11−Σ12Σ22−1Σ21.\mathbb{E}[X_1 \mid X_2 = x_2] = \mu_1 + \Sigma_{12}\Sigma_{22}^{-1}(x_2 - \mu_2), \qquad \operatorname{Cov}(X_1 \mid X_2) = \Sigma_{11} - \Sigma_{12}\Sigma_{22}^{-1}\Sigma_{21}.

The conditional covariance is the Schur complement of Σ22\Sigma_{22} in Σ\Sigma.

Derivation in four lines (worth reproducing at a whiteboard). Let B=Σ12Σ22−1B = \Sigma_{12}\Sigma_{22}^{-1} and define the residual R=X1−BX2R = X_1 - BX_2.

  1. Cov⁡(R,X2)=Σ12−BΣ22=0\operatorname{Cov}(R, X_2) = \Sigma_{12} - B\Sigma_{22} = 0.
  2. (R,X2)(R, X_2) is an affine map of XX, hence jointly normal, so zero covariance means RR is independent of X2X_2.
  3. Therefore, given X2=x2X_2 = x_2, we have X1=R+Bx2X_1 = R + Bx_2 with RR keeping its unconditional law: mean μ1−Bμ2\mu_1 - B\mu_2 and covariance Σ11−BΣ21−Σ12B⊤+BΣ22B⊤=Σ11−Σ12Σ22−1Σ21\Sigma_{11} - B\Sigma_{21} - \Sigma_{12}B^\top + B\Sigma_{22}B^\top = \Sigma_{11} - \Sigma_{12}\Sigma_{22}^{-1}\Sigma_{21}.
  4. Adding Bx2Bx_2 gives the stated mean.

The regression reading

  • B=Σ12Σ22−1B = \Sigma_{12}\Sigma_{22}^{-1} is the matrix of population regression coefficients of X1X_1 on X2X_2, and the conditional mean is the regression line (plane). In the bivariate case it reduces to slope ρ σ1/σ2\rho\,\sigma_1/\sigma_2.
  • The conditional mean E[X1∣X2]\mathbb{E}[X_1 \mid X_2] minimises mean squared error over all functions of X2X_2. For Gaussians the best predictor happens to be linear, which is why OLS is the right tool there.
  • The Schur complement is the residual variance. The fraction explained, Σ12Σ22−1Σ21/Σ11\Sigma_{12}\Sigma_{22}^{-1}\Sigma_{21} / \Sigma_{11} for scalar X1X_1, is the population R2R^2.
  • The conditional covariance does not depend on x2x_2. A surprising observation shifts your forecast but never makes you more or less certain. This is special to the Gaussian; for fat-tailed joint laws (a multivariate tt, say) an extreme observation widens the conditional spread.

Practical notes: if Σ22\Sigma_{22} is singular, some signals are exact linear combinations of others and a pseudo-inverse gives the same conditional law. Numerically, solve Σ22b=Σ21\Sigma_{22} b = \Sigma_{21} rather than forming the inverse.

Worked example

combining two correlated signals

A standardised return X1X_1 and two standardised signals X2,X3X_2, X_3 are jointly normal with mean zero and every pairwise correlation equal to 0.50.5. Today X2=1X_2 = 1 and X3=2X_3 = 2. Find the conditional distribution of X1X_1 and P(X1>0∣X2=1,X3=2)P(X_1 > 0 \mid X_2 = 1, X_3 = 2). How much does the second signal add over the first alone?

Show solution

The blocks are Σ11=1\Sigma_{11} = 1, Σ12=(0.5, 0.5)\Sigma_{12} = (0.5,\ 0.5) and

Σ22=(10.50.51),Σ22−1=10.75(1−0.5−0.51).\Sigma_{22} = \begin{pmatrix} 1 & 0.5 \\ 0.5 & 1 \end{pmatrix}, \qquad \Sigma_{22}^{-1} = \frac{1}{0.75}\begin{pmatrix} 1 & -0.5 \\ -0.5 & 1 \end{pmatrix}.

Coefficients. B=Σ12Σ22−1=10.75(0.5−0.25, −0.25+0.5)=(13, 13)B = \Sigma_{12}\Sigma_{22}^{-1} = \tfrac{1}{0.75}(0.5 - 0.25,\ -0.25 + 0.5) = (\tfrac13,\ \tfrac13).

Conditional mean. 13(1)+13(2)=1\tfrac13(1) + \tfrac13(2) = 1.

Conditional variance. 1−B Σ21=1−(13⋅0.5+13⋅0.5)=231 - B\,\Sigma_{21} = 1 - (\tfrac13 \cdot 0.5 + \tfrac13 \cdot 0.5) = \tfrac23.

So X1∣(X2,X3)=(1,2)∼N(1,23)X_1 \mid (X_2, X_3) = (1, 2) \sim N(1, \tfrac23) and

P(X1>0∣⋅)=Φ ⁣(12/3)=Φ(1.225)≈0.890.P(X_1 > 0 \mid \cdot) = \Phi\!\left(\frac{1}{\sqrt{2/3}}\right) = \Phi(1.225) \approx 0.890.

Value of the second signal. With X2X_2 alone, the residual variance is 1−0.52=0.751 - 0.5^2 = 0.75. Adding X3X_3 lowers it only to 0.6670.667, so R2R^2 rises from 0.250.25 to 0.330.33, not to 0.50.5, because X3X_3 largely repeats what X2X_2 says. Note too that each coefficient is 13\tfrac13, smaller than the single-signal slope of 12\tfrac12: correlated signals share the credit.

Worked example

Brownian motion given its endpoint

WW is a standard Brownian motion. Find the distribution of WsW_s given Wt=bW_t = b for 0<s<t0 < s < t, and evaluate it for s=1s = 1, t=4t = 4, b=2b = 2.

Show solution

(Ws,Wt)(W_s, W_t) is jointly normal with mean zero, Var⁡(Ws)=s\operatorname{Var}(W_s) = s, Var⁡(Wt)=t\operatorname{Var}(W_t) = t and Cov⁡(Ws,Wt)=min⁡(s,t)=s\operatorname{Cov}(W_s, W_t) = \min(s, t) = s. The scalar conditioning formula gives

E[Ws∣Wt=b]=st b,Var⁡(Ws∣Wt=b)=s−s2t=s(t−s)t.\mathbb{E}[W_s \mid W_t = b] = \frac{s}{t}\,b, \qquad \operatorname{Var}(W_s \mid W_t = b) = s - \frac{s^2}{t} = \frac{s(t - s)}{t}.

The conditional mean interpolates linearly to the endpoint, and the variance is zero at both ends and largest in the middle: this is the Brownian bridge. With s=1s = 1, t=4t = 4, b=2b = 2: W1∣W4=2∼N(0.5, 0.75)W_1 \mid W_4 = 2 \sim N(0.5,\ 0.75).

The same computation answers the classic "X,YX, Y i.i.d. N(0,1)N(0, 1); given X+Y=sX + Y = s, what is XX?": Cov⁡(X,X+Y)=1\operatorname{Cov}(X, X + Y) = 1 and Var⁡(X+Y)=2\operatorname{Var}(X + Y) = 2, so X∣X+Y=s∼N(s/2, 1/2)X \mid X + Y = s \sim N(s/2,\ 1/2).

How to approach these out loud

  1. Say whether the vector is jointly normal and why (built from independent normals by linear maps, or stated). If not, fall back to slicing the joint density.
  2. Write down only the blocks you need: Var⁡\operatorname{Var} of the target, Cov⁡\operatorname{Cov} of target with observed, Cov⁡\operatorname{Cov} of the observed.
  3. Conditional mean = prior mean + (covariance / variance) × surprise. Conditional variance = prior variance − explained part.
  4. Sanity-check the limits: an observation uncorrelated with the target should leave it unchanged; a perfectly correlated one should pin it down.

Knowledge check

(X1,X2)(X_1, X_2) is bivariate normal with mean zero, Var⁡(X1)=4\operatorname{Var}(X_1) = 4, Var⁡(X2)=1\operatorname{Var}(X_2) = 1 and Cov⁡(X1,X2)=1\operatorname{Cov}(X_1, X_2) = 1. You observe X2=3X_2 = 3. What is Var⁡(X1∣X2=3)\operatorname{Var}(X_1 \mid X_2 = 3)?

Knowledge check

XX and YY are i.i.d. N(0,1)N(0, 1). What is E[X2∣X+Y=2]\mathbb{E}[X^2 \mid X + Y = 2]?

Knowledge check

X and Y are each standard normal and uncorrelated. Which extra fact is enough to conclude they are independent?

Key takeaways

  • Marginalise by integrating out; condition by slicing and renormalising. Get the support right first.
  • The laws of total expectation and total variance often replace a full conditional calculation.
  • X∼N(μ,Σ)X \sim N(\mu, \Sigma) means every linear combination is normal; within it, uncorrelated means independent.
  • X1∣X2=x2∼N(μ1+Σ12Σ22−1(x2−μ2), Σ11−Σ12Σ22−1Σ21)X_1 \mid X_2 = x_2 \sim N\big(\mu_1 + \Sigma_{12}\Sigma_{22}^{-1}(x_2 - \mu_2),\ \Sigma_{11} - \Sigma_{12}\Sigma_{22}^{-1}\Sigma_{21}\big); prove it by making the residual X1−BX2X_1 - BX_2 uncorrelated with X2X_2.
  • The coefficients are population regression slopes, the Schur complement is residual variance, and for Gaussians the conditional variance does not depend on what you observed.

Practice problems

Finished reading?

Answer the 3 knowledge checks to complete this lesson (0 done).