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=431.33

Cross-check with the formula:

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

Covariance is unbounded; correlation is the normalized version:

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

210.2. Covariance and Correlation