Why is SVD of the data matrix numerically preferred over eigendecomposition of the covariance matrix for PCA?

Quick Overview

A numerical linear algebra question about computing principal component analysis through the SVD of the data matrix versus an eigendecomposition of the covariance matrix. It tests understanding of conditioning, floating-point precision, how PCA outputs map to the SVD, and solver trade-offs.

Why is SVD of the data matrix numerically preferred over eigendecomposition of the covariance matrix for PCA?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Why is SVD of the data matrix numerically preferred over eigendecomposition of the covariance matrix for PCA? Both routes give the same principal components in exact arithmetic. The question is about what happens in floating point. ```hint Relate the two decompositions Write the eigenvalues of the covariance in terms of the singular values of the centered data matrix, then think about what double precision can still represent. ``` ### What a Strong Answer Covers - How forming the covariance changes the conditioning of the problem, using the relation between eigenvalues and singular values - What that means in floating point for directions with small singular values, with a concrete scale - How to read the principal directions, variances and scores off the SVD, and the preprocessing it needs - The computational side, including when the covariance route is still a reasonable choice ### Follow-up Questions - You need to whiten the data with PCA. Why does the precision argument matter more there than when you keep only the top few components? - How would you compute PCA on data that arrives as a stream and never fits in memory? - When d is much larger than n, what would you decompose, and why? - Why can components from two PCA implementations differ in sign, and how do libraries make the output deterministic?

Overview: A numerical linear algebra question about computing principal component analysis through the SVD of the data matrix versus an eigendecomposition of the covariance matrix. It tests understanding of conditioning, floating-point precision, how PCA outputs map to the SVD, and solver trade-offs.

General logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

Why is SVD of the data matrix numerically preferred over eigendecomposition of the covariance matrix for PCA?

Both routes give the same principal components in exact arithmetic. The question is about what happens in floating point.

What a Strong Answer Covers Guidance

  • How forming the covariance changes the conditioning of the problem, using the relation between eigenvalues and singular values
  • What that means in floating point for directions with small singular values, with a concrete scale
  • How to read the principal directions, variances and scores off the SVD, and the preprocessing it needs
  • The computational side, including when the covariance route is still a reasonable choice

Follow-up Questions Guidance

  • You need to whiten the data with PCA. Why does the precision argument matter more there than when you keep only the top few components?
  • How would you compute PCA on data that arrives as a stream and never fits in memory?
  • When d is much larger than n, what would you decompose, and why?
  • Why can components from two PCA implementations differ in sign, and how do libraries make the output deterministic?