Skip to main content

10.6 Part II: Principal components analysis

Source: Ideas from Computational Physics (Landau, Páez, Bordeianu), §10.6. Rewritten in original wording. Continues 10.5b. Next: 10.6b.

Why PCA after Fourier / wavelets​

Fourier bases are infinite, correlated, and awkward to truncate. Wavelets compress 1D / image-like signals well but are a poor fit for huge, unlabeled, multivariate tables (stellar spectra, EEG arrays, faces, ocean fields). PCA rotates the measurement axes into principal components that point along directions of maximal variance (“power”) in dataspace — unsupervised dimensionality reduction, or equivalently: extract the dominant dynamics in a noisy, redundant cloud.

Same idea as principal axes for rigid-body inertia: choose coordinates where the description is simplest.

Iris warm-up​

Four features (cm): sepal length/width, petal length/width. A short set of samples (subset of the classic iris table) is enough to practice means, variances, and covariances before full eigen-PCA.

Data space RM\mathcal{R}^M​

Figure 10.13 — multiple detectors on a beam.

At each instant, MM observables form one sample vector (e.g. eight coordinates from four detectors’ (x,y)(x,y)). Thousands of times × many channels ⇒ enormous N×MN\times M tables, often noisy and correlated across detectors.

Variance and SNR​

For a scalar channel with NN samples,

zˉ=1N∑izi,σ2(z)=Var(z)=1N−1∑i(zi−zˉ)2.\bar z=\frac1N\sum_i z_i,\qquad \sigma^2(z)=\mathrm{Var}(z)=\frac1{N-1}\sum_i(z_i-\bar z)^2.

Signal-to-noise ratio

SNR=σsignal2σnoise2.\mathrm{SNR}=\frac{\sigma_{\mathrm{signal}}^2}{\sigma_{\mathrm{noise}}^2}.

PCA’s working hypothesis: largest variance ≈ most interesting dynamics; orthogonal residual directions may be noise or weaker modes.

Figure 10.14 — PC₁ along max variance; PC₂ secondary; right: projected cloud.

Covariance matrix​

Center channels ai=ai′−aˉa_i=a_i'-\bar a, bi=bi′−bˉb_i=b_i'-\bar b. Pick the sample covariance and the matrix form C=XXT/(N−1)C=\mathbf X\mathbf X^{T}/(N-1) among lookalikes.

Positive cov ⇒ channels tend to move together; large |cov| ⇒ redundancy; zero ⇒ uncorrelated (for this linear measure). Stack MM centered detector rows into an M×NM\times N matrix X\mathbf X (row = all times for one channel; column = one time across channels).

  • Diagonal CiiC_{ii}: variances of individual channels.
  • Off-diagonal CijC_{ij}: correlations between channels ii and jj.
  • CC is square, symmetric, and positive semidefinite.

PCA pipeline (2D demo)​

Figures 10.15–16 — cloud, eigenvectors, PCA coordinates.

Classic steps (Smith-style N=10N=10 points in the labs):

  1. Enter the N×2N\times 2 (or M×NM\times N) table.
  2. Center each feature (subtract column/row means).
  3. Build CC (for 2D: var x\mathrm{var}\,x, cov(x,y)\mathrm{cov}(x,y), var y\mathrm{var}\,y).
  4. Eigendecompose CC: eigenvalues λ1≥λ2≥⋯\lambda_1\ge\lambda_2\ge\cdots and orthonormal eigenvectors PC1,PC2,…\mathbf{PC}_1,\mathbf{PC}_2,\ldots. The largest λ\lambda is the principal direction — often most of the power (λ1/(∑λ)\lambda_1/(\sum\lambda)).
  5. Project: form a feature matrix FF whose columns (or rows) are the kept PCs; compute XPCA=FTXTX^{\mathrm{PCA}}=F^{T} X^{T} (convention: match your layout). Keeping only PC1\mathbf{PC}_1 collapses the cloud onto a line; two PCs recover a rotated plane.

Demonstration numbers (2D)​

For the Smith cloud (labs table), after centering you should recover something like

C≈[0.61660.61540.61540.7166],λ1≈1.284,λ2≈0.049,λ1λ1+λ2≈96%,C\approx\begin{bmatrix}0.6166&0.6154\\0.6154&0.7166\end{bmatrix}, \quad \lambda_1\approx 1.284,\quad \lambda_2\approx 0.049, \quad \frac{\lambda_1}{\lambda_1+\lambda_2}\approx 96\%,

with unit PC1≈(−0.678,−0.735)\mathbf{PC}_1\approx(-0.678,-0.735) (sign is conventional — flip both components together). PC2\mathbf{PC}_2 is orthogonal and carries the leftover few percent. Projecting a centered sample r\mathbf r is the score PC1⋅r\mathbf{PC}_1\cdot\mathbf r (and optionally PC2⋅r\mathbf{PC}_2\cdot\mathbf r).

Iris remains your open problem: same pipeline in M=4M=4. Chaotic-pendulum phase-space samples (Chapter 8) make a nice physics follow-on — store ∼10\sim 10 cycles past transients and PCA the (θ,ω)(\theta,\omega) (or higher) table.

Takeaway​

  1. Center features.
  2. Form C=1N−1XXTC=\frac1{N-1}XX^{T}.
  3. Eigendecompose → ordered PCs.
  4. Project onto the top kk PCs (drop small-λ\lambda “noise” directions).
Quiz

PCA and covariance

1 / 4

With centered X (M×N), the covariance matrix is…

Pick an answer to see if you are right.

Next: 10.6b PCA labs.