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·E(X) + (1 − w)·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

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

  3. Correlation bends the curve

    At ρ = +1 the mixes lie on a straight line between X and Y, so there is no benefit. At ρ = −1 the curve touches sd = 0. Every ρ below +1 bends the curve to the left of that line.

  4. The minimum-variance mix

    Set the derivative of Var(P) in w to zero. For Tortoise and Hare at ρ = 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
E(aX + bY) = aE(X) + bE(Y)
Var(aX + bY) = a²Var(X) + b²Var(Y) + 2ab Cov(X, Y)
Cov(X, Y) = ρ · sd(X) · sd(Y)
Minimum-variance weight
w* = (σY² − ρσXσY) / (σX² + σY² − 2ρσXσ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 (ρ ≈ +0.85), so mixing them is not really diversification.

Expectation and variance

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

Var(X) = E(X²) − E(X)²

Correlation is unit-free

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

corr(X, Y) = Cov(X, Y) / (sd(X) 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 ρ ≈ 0 between them, n equal bets cut the variance roughly by a factor of n.

Var(average of n independent bets) = σ² / n

Try this in class

  1. Load Tortoise & Hare. Read 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 ρ 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 (ρ = 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 ρ = 0. Show that w* = 0.5 and that the 50/50 SD is the single-asset SD divided by √2.