core practice · implementation task

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.

The mechanism

Covariance is signed co-fluctuation with units. Correlation divides by both standard deviations so scale cancels. Zero correlation means no linear relationship, not independence.

Study Covariance & Correlation

Expected evidence

Symmetric matrices; corr[i,j] = cov[i,j]/(σ_i σ_j).

Try this drill in the practice workspace →

Hints when you need them
  • Center each series first for covariance.
  • Correlation is scale-free.

Watch for these 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

Check the sources

Browse all practice briefs