NewTurn any lesson into a live trading bot with one prompt, using AgenKitagenkit.xyz

Part 1 · ProbabilityLesson 310 minQuant Bible §2.2

Variance, and why diversification works

How spread adds up, the √n rule for averages, and standard deviations as arrows.

The mean tells you where a bet lands on average. Variance tells you how far it lands from there, and in trading that is the difference between a strategy you can run and one that blows up before its edge shows.

Definition

Variance is the expected squared distance from the mean, and the standard deviation σ\sigma is its square root, in the same units as XX:

Var⁡(X)=E[(X−μ)2]=E[X2]−(E[X])2,σ=Var⁡(X).\operatorname{Var}(X) = E\big[(X-\mu)^2\big] = E[X^2] - \big(E[X]\big)^2, \qquad \sigma = \sqrt{\operatorname{Var}(X)} .

The second form comes from expanding the square and using linearity. For a fair die, E[X2]=91/6E[X^2] = 91/6 and E[X]2=12.25E[X]^2 = 12.25, so Var⁡(X)=35/12≈2.92\operatorname{Var}(X) = 35/12 \approx 2.92 and σ≈1.71\sigma \approx 1.71.

How variance scales and adds

Shifting a variable doesn’t change its spread; scaling it scales the spread:

Var⁡(aX+b)=a2 Var⁡(X).\operatorname{Var}(aX + b) = a^2\,\operatorname{Var}(X).

For sums, there is a cross term:

Var⁡(X+Y)=Var⁡(X)+Var⁡(Y)+2Cov⁡(X,Y).\operatorname{Var}(X + Y) = \operatorname{Var}(X) + \operatorname{Var}(Y) + 2\operatorname{Cov}(X, Y).

Only when XX and YY are uncorrelated does it reduce to Var⁡(X)+Var⁡(Y)\operatorname{Var}(X) + \operatorname{Var}(Y). The original states that version without the condition; it is the most common slip in interviews, so say “if independent” out loud.

Standard deviations are arrows

Write Cov⁡(X,Y)=ρ σXσY\operatorname{Cov}(X,Y) = \rho\,\sigma_X\sigma_Y and the formula becomes σX+Y2=σX2+σY2+2ρσXσY\sigma_{X+Y}^2 = \sigma_X^2 + \sigma_Y^2 + 2\rho\sigma_X\sigma_Y. That is the law of cosines. Draw σX\sigma_X and σY\sigma_Y as arrows with the angle between them set so that cos⁡(angle)=ρ\cos(\text{angle}) = \rho, and the volatility of the sum is the length of the resultant arrow.

Figure 3.1Volatility as arrows, in 3D
Correlation sets the angle. At ρ = 1 the arrows point the same way and risks simply add. At ρ = 0 they are perpendicular (Pythagoras). Switch to the hedge X − Y: with high correlation the resultant almost vanishes, which is exactly what a hedge is for.

This picture also explains the three-correlations puzzle in lesson 5: three arrows can’t have arbitrary pairwise angles.

The √n rule

If X1,…,XnX_1, \dots, X_n are independent with variance σ2\sigma^2 each,

Var⁡(∑Xi)=nσ2,Var⁡(Xˉ)=σ2n,sd⁡(Xˉ)=σn.\operatorname{Var}\Big(\sum X_i\Big) = n\sigma^2, \qquad \operatorname{Var}(\bar X) = \frac{\sigma^2}{n}, \qquad \operatorname{sd}(\bar X) = \frac{\sigma}{\sqrt n}.

Averaging nn independent things shrinks the noise by n\sqrt n, not nn. Four times the data halves the error. If every pair has correlation ρ\rho instead, Var⁡(Xˉ)=σ2(1n+(1−1n)ρ)\operatorname{Var}(\bar X) = \sigma^2\big(\tfrac1n + (1-\tfrac1n)\rho\big), which never falls below ρσ2\rho\sigma^2.

Figure 3.2The √n rule, and its floor
Top: 160 single draws against 160 averages of n draws, with ±1σ shaded. Bottom: σ of the average as n grows. Raise the correlation and the curve flattens onto a floor of √ρ: adding more correlated bets stops reducing risk.

In code

import numpy as np
rng = np.random.default_rng(2)

sx, sy, rho = 3.0, 2.0, 0.3
print(np.sqrt(sx**2 + sy**2 + 2 * rho * sx * sy))   # sd of X + Y: 4.07
print(np.sqrt(sx**2 + sy**2 - 2 * rho * sx * sy))   # sd of the hedge X - Y: 3.07

# Averages of n draws shrink like 1/sqrt(n)
for n in (1, 4, 16, 64):
    means = rng.standard_normal((100_000, n)).mean(axis=1)
    print(n, round(means.std(), 3), round(1 / np.sqrt(n), 3))

Check yourself

Two strategies each have annual volatility 10% and correlation 0.5. You run both with equal capital (half in each). What is the volatility of the combined book?

Progress is saved in this browser only.