Polson–Sokolov Lab · Expectation, variance and covariance

Portfolio Lab

Put a fraction w of your money in X and the rest in Y. Move the weight and the correlation and watch the portfolio's mean and risk update, term by term. The left chart traces every mix from all-Y to all-X; the right chart shows the joint draws behind it.

← All labs

Based on Chapter 1, Probability and Uncertainty, of Polson and Sokolov, Bayes, Artificial Intelligence, and Deep Learning (vsokolov.org/html/_book).

Risk and return of P = wX + (1 − w)Y

Simulated joint returns

All in X All in Y Your portfolio Minimum variance Mixes at the current ρ Mixes at ρ = −1, 0, +1

Diversification

Variances add, plus a cross term

Tortoise and Hare both sell 1.5 cars on average. Tortoise sells 1 or 2 (Var 0.25), Hare sells 0 or 3 (Var 2.25). Assume they are independent and splits the business 50/50. The variance falls to 0.625 with the same expected sales.

  1. The mean is a weighted average

    \(E(wX + (1 - w)Y)\) \(= w \cdot E(X) + (1 - w) \cdot E(Y)\). Mixing never changes the mean in a surprising way. The portfolio dot always sits between the two assets vertically.

  2. The variance has a cross term

    \(\mathrm{Var}(aX + bY)\) \(= a^2\mathrm{Var}(X) + b^2\mathrm{Var}(Y)\) \({} + 2ab \cdot \mathrm{Cov}(X, Y)\). The last piece is the diversification term. With \(\mathrm{Cov} > 0\) it adds risk; with \(\mathrm{Cov} < 0\) it removes risk.

  3. Correlation bends the curve

    At \(\rho = +1\) the mixes lie on a straight line between \(X\) and \(Y\), so there is no benefit. At \(\rho = -1\) the curve touches \(\mathrm{sd} = 0\). Every \(\rho\) below +1 bends the curve to the left of that line.

  4. The minimum-variance mix

    Set the derivative of \(\mathrm{Var}(P)\) in \(w\) to zero. For Tortoise and Hare at \(\rho = 0\) this gives \(w^* = 2.25 / 2.5 = 0.9\), with Var 0.225. That is less risky than Tortoise alone, because a little Hare averages away some of Tortoise's own noise.

Linear combinations
\(\displaystyle E(aX + bY) = aE(X) + bE(Y) \)
\(\displaystyle \mathrm{Var}(aX + bY) = a^2\mathrm{Var}(X) + b^2\mathrm{Var}(Y) + 2ab\,\mathrm{Cov}(X, Y) \)
\(\displaystyle \mathrm{Cov}(X, Y) = \rho \cdot \mathrm{sd}(X) \cdot \mathrm{sd}(Y) \)
Minimum-variance weight
\(\displaystyle w^* = \frac{\sigma_Y^2 - \rho\sigma_X\sigma_Y}{\sigma_X^2 + \sigma_Y^2 - 2\rho\sigma_X\sigma_Y} \)
Tortoise (X) and Hare (Y)
MixρVar(P)sd(P)
All Tortoise–0.2500.500
All Hare–2.2501.500
50/5000.6250.791
w* = 0.900.2250.474
w* = 0.75−10.0000.000

Takeaway for students. The benefit of mixing depends on the correlation, and correlations change with the regime. The 2022 lesson: stocks and bonds fell together when both reacted to the same Fed shock, and the diversification from bonds disappeared. Compare the two SPY / TLT presets. Growth and value move together (\(\rho \approx +0.85\)), so mixing them is not really diversification.

Expectation and variance

The coin that pays $2 or $0 has \(E(X) = \$1\) and \(\mathrm{Var}(X) = 1\). One play never pays $1, so the mean is not the whole story.

\[ \mathrm{Var}(X) = E(X^2) - E(X)^2 \]

Correlation is unit-free

Covariance has awkward units (cars × cars, or %²). Dividing by both SDs gives a number between −1 and +1.

\[ \operatorname{corr}(X, Y) = \frac{\mathrm{Cov}(X, Y)}{\mathrm{sd}(X)\,\mathrm{sd}(Y)} \]

Prediction markets as a portfolio

The Polymarket basket spreads bets over a World Cup, a tech market-cap race and a US primary. With \(\rho \approx 0\) between them, \(n\) equal bets cut the variance roughly by a factor of \(n\).

\[ \mathrm{Var}(\text{average of } n \text{ independent bets}) = \sigma^2 / n \]

Try this in class

  1. Load Tortoise & Hare. Read \(\mathrm{Var}(P) = 0.625\) off the formula line, then drag \(w\) to 0.9. Ask why adding a little of the risky Hare lowers the risk.
  2. Keep \(w = 0.5\) and drag \(\rho\) from −1 to +1. Watch the cross term in the formula change sign and the right-hand cloud tilt.
  3. Switch to SPY / TLT, then to the 2022 preset. The curve straightens and the minimum-variance portfolio becomes riskier. Same assets, different correlation.
  4. Load VUG / VTV (\(\rho = 0.85\)). Find how much risk a 50/50 blend saves compared with the straight line between the two funds.
  5. Set both SDs equal and \(\rho = 0\). Show that \(w^* = 0.5\) and that the 50/50 SD is the single-asset SD divided by \(\sqrt{2}\).