5.5.2Portfolio Theory

Learn correlation and covariance

1,682 words8 min readdifficulty · medium

WHY do we even need this?


WHAT is covariance?

HOW: deriving covariance from scratch

Start from the idea "do the deviations agree in sign?"

  1. Deviation of XX from its centre: dX=XμXd_X = X-\mu_X.
  2. Deviation of YY: dY=YμYd_Y = Y-\mu_Y.
  3. Multiply them. If both positive or both negative, dXdY>0d_X d_Y>0. If they disagree in sign, dXdY<0d_X d_Y<0. So the sign of the product literally records "same direction or opposite."
  4. Average over all outcomes to summarise the tendency: Cov(X,Y)=E[dXdY].\operatorname{Cov}(X,Y)=\mathbb{E}[d_X d_Y].

Sample version (from nn historical data points), which is what you actually compute: Cov(X,Y)=1n1i=1n(xixˉ)(yiyˉ)\operatorname{Cov}(X,Y)=\frac{1}{n-1}\sum_{i=1}^{n}(x_i-\bar x)(y_i-\bar y) Why n1n-1? We used the data twice — once to estimate xˉ\bar x, once for deviations — so we "used up" one degree of freedom; dividing by n1n-1 corrects the resulting downward bias.


WHAT is correlation?

HOW: why correlation is bounded by ±1\pm1

Divide by the standard deviations to get standardised variables ZX=(XμX)/σXZ_X=(X-\mu_X)/\sigma_X (mean 0, variance 1). Then ρXY=E[ZXZY]\rho_{XY}=\mathbb{E}[Z_X Z_Y].

Consider the always-nonnegative quantity: E[(ZXZY)2]0.\mathbb{E}\big[(Z_X - Z_Y)^2\big]\ge 0. Expand: E[ZX2]2E[ZXZY]+E[ZY2]=12ρ+10ρ1.\mathbb{E}[Z_X^2] - 2\mathbb{E}[Z_XZ_Y] + \mathbb{E}[Z_Y^2] = 1 - 2\rho + 1 \ge 0 \Rightarrow \rho \le 1. Similarly E[(ZX+ZY)2]0\mathbb{E}[(Z_X+Z_Y)^2]\ge0 gives ρ1\rho\ge -1. Hence 1ρ1-1\le\rho\le1. (This is the Cauchy–Schwarz inequality in disguise.)

Figure — Learn correlation and covariance

WHY this matters: portfolio variance


Worked examples


Common mistakes (Steel-manned)


Recall Explain to a 12-year-old (Feynman)

Imagine two friends on a see-saw. Covariance asks: when one goes up, does the other go up too, or down? A positive number = they go up together; negative = one up, one down. But covariance uses weird units, so it's hard to say if it's "a lot." Correlation is the same idea but scored fairly from 1-1 to +1+1: +1+1 = perfect same-direction team, 1-1 = perfect opposite see-saw, 00 = no pattern. In investing, you want friends who zig when others zag — because when one stock drops, the other lifts your basket back up.


Flashcards

What does covariance measure?
The average product of two variables' deviations from their means — the direction & raw magnitude of their co-movement.
Definition formula for covariance?
Cov(X,Y)=E[(XμX)(YμY)]\operatorname{Cov}(X,Y)=\mathbb{E}[(X-\mu_X)(Y-\mu_Y)].
Computational form of covariance?
Cov(X,Y)=E[XY]μXμY\operatorname{Cov}(X,Y)=\mathbb{E}[XY]-\mu_X\mu_Y.
How is correlation defined from covariance?
ρXY=Cov(X,Y)/(σXσY)\rho_{XY}=\operatorname{Cov}(X,Y)/(\sigma_X\sigma_Y).
Range of the correlation coefficient?
1ρ+1-1 \le \rho \le +1.
Why divide by σXσY\sigma_X\sigma_Y?
To remove units/scale, giving a dimensionless, comparable strength score bounded by ±1\pm1.
Does ρ=0\rho=0 imply independence?
No — it only rules out a linear relationship; nonlinear dependence can still exist.
Two-asset portfolio variance formula?
σP2=wA2σA2+wB2σB2+2wAwBρABσAσB\sigma_P^2=w_A^2\sigma_A^2+w_B^2\sigma_B^2+2w_Aw_B\rho_{AB}\sigma_A\sigma_B.
Which correlation gives the greatest diversification benefit?
The most negative one (ρ=1\rho=-1 can drive portfolio variance to 0).
Why use n1n-1 in sample covariance?
Bessel's correction — the mean was estimated from the data, so one degree of freedom is lost; corrects downward bias.
Inequality proving ρ1|\rho|\le1?
Cauchy–Schwarz, via E[(ZX±ZY)2]0\mathbb{E}[(Z_X\pm Z_Y)^2]\ge0 with standardised variables.

Connections

  • Variance and Standard Deviation — the building blocks σX,σY\sigma_X,\sigma_Y.
  • Diversification — why negative correlation reduces risk.
  • Portfolio Variance — where covariance enters directly.
  • Efficient Frontier — correlation shapes the frontier's curve.
  • Beta and CAPM — beta =Cov(Ri,Rm)/Var(Rm)=\operatorname{Cov}(R_i,R_m)/\operatorname{Var}(R_m).
  • Cauchy–Schwarz Inequality — the math bounding ρ\rho.

Concept Map

insufficient for

depends on

measured by

defined as

expand to

estimate via

corrects

has scale problem

fixed by rescaling

formula

bounded in

enables

Variance risk of one stock

Portfolio risk

Co-movement of pairs

Covariance

E[(X-muX)(Y-muY)]

E[XY] - muX muY

Sample form with n-1

Downward bias / lost degree of freedom

Depends on units

Correlation rho

Cov / (sigmaX sigmaY)

Range -1 to +1

Diversification

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, jab tum do stocks ek saath hold karte ho, toh sirf yeh matter nahi karta ki har stock apne aap mein kitna up-down hota hai. Asli cheez hai — dono ek saath kaise move karte hain? Yahi batati hai covariance. Simple idea: har stock ke return ka apne average se deviation nikaalo, dono ke deviations ko multiply karo, aur average le lo. Agar dono usually same direction mein jaate hain toh number positive, opposite direction mein jaate hain toh negative.

Problem yeh hai ki covariance ka number units pe depend karta hai, toh "yeh bada hai ya chhota" bolna mushkil. Isliye hum use standardise karte hain — covariance ko dono ke standard deviations se divide kar do, aur mil jaata hai correlation (ρ\rho), jo hamesha 1-1 se +1+1 ke beech hota hai. +1+1 matlab perfect saath-saath, 1-1 matlab perfect ulta, 00 matlab koi linear pattern nahi.

Investing mein iska matlab bada powerful hai. Diversification ka poora fayda correlation se aata hai. Yaad rakho: "Rho low, risk low." Agar do stocks ka ρ\rho negative hai, toh ek girta hai jab doosra chadhta hai — isse tumhare portfolio ka risk kam ho jaata hai, kabhi-kabhi to zero bhi (ρ=1\rho=-1 pe). Isiliye smart investor sirf "achhe stocks" nahi dhoondhta, balki aise stocks dhoondhta hai jo aapas mein kam correlated hon.

Ek warning: ρ=0\rho=0 ka matlab yeh nahi hai ki dono independent hain — yeh sirf linear relation ko rule out karta hai. Aur ρ\rho kabhi bhi 11 se zyada nahi ho sakta; agar aayega, toh calculation mein galti hui hai.

Test yourself — Portfolio Theory

Connections