210. Covariance & Correlation

210.1. Covariance

Cov(𝑋,𝑌)=𝔼[(𝑋−𝔼[𝑋])(𝑌−𝔼[𝑌])]=𝔼[𝑋𝑌]−𝔼[𝑋]𝔼[𝑌]∑𝑖=1𝑛(𝑥𝑖−𝑥̄)(𝑦𝑖−𝑦̄)𝑛
Example
𝑋=(1,2,3)𝑌=(2,4,6)𝔼[𝑋]=1+2+33=2𝔼[𝑌]=2+4+63=4
𝑥𝑖𝑦𝑖𝑥𝑖−𝔼[𝑋]𝑦𝑖−𝔼[𝑌]product
12−1−22
24000
36122
Cov(𝑋,𝑌)=2+0+23=43≈1.33

Cross-check with the formula:

𝔼[𝑋𝑌]−𝔼[𝑋]𝔼[𝑌]𝔼[𝑋𝑌]=(1)(2)+(2)(4)+(3)(6)3=2+8+183=283𝔼[𝑋]𝔼[𝑌]=(2)(4)=8𝔼[𝑋𝑌]−𝔼[𝑋]𝔼[𝑌]=283−8=43

Covariance is unbounded; correlation is the normalized version:

𝜌𝑋𝑌=Cov(𝑋,𝑌)𝜎𝑋𝜎𝑌

210.2. Covariance and Correlation