Module 9Covariance & CorrelationLesson 5 of 820 min
Correlation
rho = cov / (sx*sy) with zero-vol guards.
Correlation
Bounded [-1,1] (numerically — watch floating noise).
Degenerate cases
If either std is 0, define rho=0 or return None.
Challenge
Print pairwise corr matrix for 3 assets (lists of rets).
Tips
- Guard division by zero
- rho near 1 = co-movement
- Matrix form offline with ndarray
Try it live
CorrelationRust 2021
Loading editor…
Output
Press Run to compile and execute.