๐Ÿงฎ Brain Teaser

The Variance That Vanishes: Why PCA Features Are Uncorrelated

You fit PCA to a data matrix XโˆˆRnร—pX \in \mathbb{R}^{n \times p} (columns centered). Let v1,v2,โ€ฆ,vpv_1, v_2, \ldots, v_p be the principal components (eigenvectors of the sample covariance matrix S=1nXTXS = \frac{1}{n}X^T X, ordered by decreasing eigenvalue ฮป1โ‰ฅฮป2โ‰ฅโ‹ฏโ‰ฅฮปp\lambda_1 \geq \lambda_2 \geq \cdots \geq \lambda_p).

Define the scores zk=XvkโˆˆRnz_k = X v_k \in \mathbb{R}^n for each kk.

(a) Show that the sample variance of the scores zkz_k equals ฮปk\lambda_k.

(b) Show that the scores zjz_j and zkz_k are sample-uncorrelated for jโ‰ kj \neq k, i.e., zjTzk=0z_j^T z_k = 0.

(c) Here is the conceptual puzzle: the original features x1,โ€ฆ,xpx_1, \ldots, x_p (columns of XX) may be highly correlated. PCA produces perfectly uncorrelated scores. Where did the correlation go? Give a one-paragraph intuitive explanation without formulas.

PCAcovariance matrixspectral theoremdimensionality reductiondecorrelation

Answer: The Variance That Vanishes: Why PCA Features Are Uncorrelated

Key Idea / Intuition

The sample covariance matrix SS captures all pairwise correlations among features. PCA finds an orthogonal change of basis that simultaneously diagonalizes SS โ€” this is just the spectral theorem for symmetric matrices. In the new basis, the "variance budget" of the data is redistributed along directions of maximal spread, and the off-diagonal correlations literally become zero because the eigenvectors are orthogonal. The correlation didn't disappear โ€” it was rotated into pure variance along each principal axis.


Formal Proof / Solution

Setup

The sample covariance matrix is S=1nXTXS = \frac{1}{n} X^T X. Since SS is real symmetric, the spectral theorem gives

Svk=ฮปkvk,vjTvk=ฮดjk.S v_k = \lambda_k v_k, \quad v_j^T v_k = \delta_{jk}.

Part (a): Sample variance of scores equals ฮปk\lambda_k

The score vector is zk=XvkโˆˆRnz_k = X v_k \in \mathbb{R}^n.

The sample mean of zkz_k: since columns of XX are centered, XT1=0X^T \mathbf{1} = 0, so 1Tzk=1TXvk=0\mathbf{1}^T z_k = \mathbf{1}^T X v_k = 0. The scores are automatically mean-zero.

The sample variance is:

Var(zk)=1nzkTzk=1n(Xvk)T(Xvk)=1nvkTXTXvk=vkTSvk.\text{Var}(z_k) = \frac{1}{n} z_k^T z_k = \frac{1}{n} (X v_k)^T (X v_k) = \frac{1}{n} v_k^T X^T X v_k = v_k^T S v_k.

Since Svk=ฮปkvkS v_k = \lambda_k v_k and vkTvk=1v_k^T v_k = 1:

Var(zk)=vkT(ฮปkvk)=ฮปk.โœ“\text{Var}(z_k) = v_k^T (\lambda_k v_k) = \lambda_k. \quad \checkmark

Part (b): Scores are sample-uncorrelated

For jโ‰ kj \neq k:

1nzjTzk=1n(Xvj)T(Xvk)=1nvjTXTXvk=vjTSvk.\frac{1}{n} z_j^T z_k = \frac{1}{n}(X v_j)^T (X v_k) = \frac{1}{n} v_j^T X^T X v_k = v_j^T S v_k.

Now use Svk=ฮปkvkS v_k = \lambda_k v_k:

vjTSvk=ฮปkโ€‰vjTvk=ฮปkโ‹…0=0,v_j^T S v_k = \lambda_k \, v_j^T v_k = \lambda_k \cdot 0 = 0,

since eigenvectors of a symmetric matrix for distinct eigenvalues are orthogonal (and even when ฮปj=ฮปk\lambda_j = \lambda_k, we choose an orthonormal basis within each eigenspace). โœ“\quad \checkmark

Note: This calculation is exactly the statement that SS is diagonalized by V=[v1โ‹ฏvp]V = [v_1 \cdots v_p]: 1n(XV)T(XV)=VTSV=ฮ›=diag(ฮป1,โ€ฆ,ฮปp).\frac{1}{n} (XV)^T (XV) = V^T S V = \Lambda = \mathrm{diag}(\lambda_1, \ldots, \lambda_p).

Part (c): Where did the correlation go?

The original features correlate because they share underlying "directions of variation" โ€” e.g., two financial stocks both driven by a common market factor. PCA identifies those directions explicitly: the first principal component points along the axis of maximum joint variation, the second along the next most, and so on, all forced to be mutually perpendicular. By projecting onto these axes, we decompose the total variance cleanly โ€” each score captures one "pure" source of variation and is blind to the others. The correlations weren't destroyed; they were reorganized: what appeared as cross-feature covariance is now concentrated entirely on the diagonal (the eigenvalues), while the off-diagonal entries vanish by orthogonality. Think of it as rotating the data cloud so its principal axes align with the coordinate axes โ€” a tilted ellipse becomes an axis-aligned one, and axis-aligned ellipses have uncorrelated coordinates.


Summary Table

| Quantity | Value | |---|---| | Var(zk)\text{Var}(z_k) | ฮปk\lambda_k | | Cov(zj,zk)\text{Cov}(z_j, z_k), jโ‰ kj\neq k | 00 | | Total variance preserved | โˆ‘kฮปk=tr(S)\sum_k \lambda_k = \text{tr}(S) |

The last row is the trace invariance: rotation preserves total variance, just redistributes it.

Source: The Elements of Statistical Learning, Ch. 3 & 14 (Hastie, Tibshirani, Friedman)

Type: ML/StatsSource: The Elements of Statistical Learning, Ch. 3 & 14 (Hastie, Tibshirani, Friedman)Edit on GitHub โ†—