Mathematics · core
Covariance & Correlation
Covariance measures co-movement; correlation normalizes to [−1, 1]. Foundation for regression, PCA, and portfolio risk.
Mental model
Covariance is signed co-fluctuation with units. Correlation divides by both standard deviations so scale cancels. Zero correlation means no linear relationship, not independence.
How to study Covariance & Correlation
Begin by restating the mental model in your own words, then connect it to a concrete system you have built or operated. Name the mechanism, the constraint it addresses, and the trade-off it introduces. Use Seeing Theory — Regression to check details, but close the source before writing your explanation. Retrieval is the learning step; rereading is only preparation.
Next, compare Covariance & Correlation with Linear Regression, Sharpe, Drawdown & Portfolio Risk, PCA & Projection. Ask what changes in correctness, latency, resource use, operability, and failure recovery. Complete Compute covariance and correlation matrix and preserve the command, input, output, and one failed attempt as evidence. Finish by explaining the idea without jargon to someone who has not studied the track.
Proof of understanding
- Explain the mechanism from first principles and identify the state it reads or changes.
- Give one situation where the concept is the right choice and one where it is not.
- Predict a realistic failure mode before running the drill, then compare the prediction with evidence.
- Connect the result to a roadmap or build artifact instead of treating the concept as isolated trivia.
Where it matters
Feature selection, portfolio diversification, multicollinearity checks.
Common mistakes
- Treating correlation 0 as unrelated when nonlinear dependence exists
- Computing correlation on price levels instead of returns
- Mixing sample n vs n−1 denominators
Learn from primary sources
- Seeing Theory — Regression (article)
Practice and explain it back
Compute covariance and correlation matrix
Given 3 aligned series (n=20 each), compute the 3×3 sample covariance matrix and correlation matrix by hand or in code (loops only). Verify diagonal covariances equal variances and corr diagonal = 1.
Expected evidence: Symmetric matrices; corr[i,j] = cov[i,j]/(σ_i σ_j).
Open the interactive drill →Review prompts
- Covariance vs correlation?
Build evidence
Implement mean, variance, correlation from scratch
On a real CSV (or synthetic data), compute mean, variance, std dev, covariance, and Pearson r without pandas/numpy — loops only.
- Functions: mean, variance (sample), covariance, correlation
- Spot-check against a calculator on 5 hand-picked pairs
- Document when you would use median instead of mean on this dataset
Volatility, Sharpe, drawdown, correlation matrix
On 2–5 tickers: annualized vol, Sharpe (assume rf=0 or document rate), max drawdown, pairwise correlation matrix.
- All metrics computed from returns you built (not pre-built risk APIs)
- Correlation matrix symmetric, diag = 1
- One paragraph interpreting whether diversification shows up