Covariance and correlation — the math of diversification
▸ Pretest — guess, even if you don't know
Two stocks each have 20% annual volatility. You put half your money in each. Their returns are uncorrelated. What's the portfolio's volatility?
Covariance: do they move together?
Volatility (A2-02) describes one return series in isolation. Portfolios live or die by a different question: when stock A has a bad day, what does stock B tend to do? Covariance is that question as a number:
Read the inside term day by day for two stocks. On a day when both are above their means, the product of deviations is positive × positive. Both below: negative × negative — positive again. One up, one down: the product is negative. Covariance averages these products:
- Positive covariance — they tend to be on the same side of their means together (two US banks).
- Near zero — no linear tendency either way (a tech stock and wheat futures, roughly).
- Negative — one tends to be up when the other is down (equities and long-dated Treasuries, in some regimes).
Note : variance is covariance with yourself.
Correlation: covariance you can interpret
Covariance has awkward units (return × return) and its magnitude scales with each asset's volatility, so "Cov = 0.0002" is uninterpretable on its own. Normalize away the scales:
The bounds are a theorem (Cauchy–Schwarz), not a convention. means an exact increasing linear relationship, an exact decreasing one, no linear relationship (a perfect U-shape can have — correlation only sees lines). Typical daily-return correlations: two large-cap US stocks 0.3–0.6; a stock with its own sector ETF 0.7–0.9.
The sample versions replace expectations with averages, with the same Bessel correction as A2-02 — numpy's np.cov uses ddof=1 by default (unlike np.std, which defaults to ddof=0; a classic gotcha):
cov_xy = np.cov(x, y)[0, 1] # 2x2 matrix; off-diagonal is Cov(x, y)
corr_xy = cov_xy / (x.std(ddof=1) * y.std(ddof=1))
The payoff: portfolio variance
From A1-04, for portfolio weights and :
Everything about diversification hides in that last term. Work the pretest example properly: , , so the first two terms give , and :
| Correlation | Portfolio variance | Portfolio volatility |
|---|---|---|
The lesson of the table: diversification is a correlation play, not a headcount play. At you get nothing — you own one asset wearing two tickers. Real diversification benefit only appears as drops below 1, and it's why a portfolio of 30 highly correlated tech stocks is far less diversified than 5 genuinely unrelated return streams.
Two honest warnings
Correlation is not causation — and it isn't stable either. Beyond the classic inferential trap (A1-05's conditional-is-not-causal, in linear clothing), financial correlations are estimated from a window and drift across regimes, just like volatility in A2-02.
"Correlations go to 1 in a crash." The trading floor version is exaggerated but points at something real: measured correlations between risky assets rise sharply in crises — assets that looked pleasantly independent in calm markets fall together when everyone deleverages at once. (One technical caveat: correlation measured conditional on high-volatility periods is mechanically higher even if the true relationship never changed, so part of the effect is a measurement artifact — but the economic core is real.) The practical consequence is brutal: diversification measured in calm markets overstates the protection you'll have in the storm, which is precisely when you need it. Never size positions assuming calm-period correlations hold in a tail event.
Forward pointer: regression beta (A2-06) is — covariance rescaled by the market's variance instead of by both standard deviations. Correlation and beta are the same object under two different normalizations.
Try it
Implement corr(x, y): the sample correlation of two equal-length arrays — sample covariance (np.cov uses ddof=1 by default) divided by the product of the two sample standard deviations (std with ddof=1).
⧉ Review cardDefine covariance and give the sign intuition.
⧉ Review cardWhat is correlation and why use it instead of covariance?
⧉ Review cardWhat is Var(aX + bY), and where does diversification live in it?
⧉ Review cardWhat happens to correlations between risky assets in a crisis?
⧉ Review cardHow does beta relate to covariance and correlation?
Map it
On paper, draw a concept map connecting: variance, covariance, correlation, Var(aX+bY), diversification, crisis correlation, and beta. Draw a labelled arrow for each relationship (e.g., which normalization turns covariance into correlation? into beta? which term of the portfolio-variance formula does diversification act through?).
◈ Calibration check
Could you compute a sample correlation from scratch and explain, with the formula, why diversification fails at correlation +1?
1 = guessing · 5 = could teach it
⏻ End of lesson
Mark it read to book its 5 review cards into your deck.
Sources & further reading
- bookWasserman (2004), All of Statistics — §3
- bookBodie, Kane & Marcus (2014), Investments, 10e — §6, 7