Project DelphiTensors Workshop

Covariance, eigenvectors and SVD

Center the data, A = X − μ. Then:

  • Covariance: C = AᵀA / (n − 1), shape (p, p) — one einsum contracting the sample axis.
  • Eigendecomposition: C vⱼ = λⱼ vⱼ, largest first.
  • SVD: A = UΣVᵀ; keep Vₖ. Scores S = AVₖ = UₖΣₖ, reconstruction X̂ = SVₖᵀ + μ, and λⱼ = σⱼ² / (n − 1).

The training residual at rank k equals the sum of the discarded squared singular values — and you must add the mean back to reconstruct raw sensor values.

Direct SVD is preferred because forming AᵀA squares the condition ratio.