Advanced Mathematics

Principal Component Analysis

Finding the directions along which data varies most: the top eigenvectors of its covariance matrix, used to compress and visualise data.

Needs a step first: 28

Centre the data, form its covariance matrix, and find that matrix's eigenvectors. The one with the largest eigenvalue is the first principal component, the direction of greatest spread; each eigenvalue is the variance along its direction. Keeping only the top few components gives the best low-dimensional approximation of the data in the least-squares sense, which is the singular value decomposition at work. PCA is the first example of learning a representation without labels, the idea that embeddings carry much further.

Where it shows up: Low-dimensional summaries like this lead to embeddings, and the same eigen-analysis appears in quantum mechanics as finding observables' eigenstates.

How to hold it: In your head

See principal components as the directions the data spreads along most, the top eigenvectors of the covariance matrix, each eigenvalue being the variance along its direction; a library finds them for you.

What knowing it looks like

  • Compute the covariance matrix of a few 2D points and find its principal components.
  • Say what fraction of the variance the first component explains.
  • Project points onto the first component and reconstruct them from it.

Test yourself

The points (2,2)(2, 2), (−2,−2)(-2, -2), (1,−1)(1, -1), (−1,1)(-1, 1) have mean zero. Using the covariance matrix with divisor n=4n = 4, find the principal components, the share of variance the first explains, and each point's coordinate along the first component.
Show the worked answer
∑x2=10\sum x^2 = 10, ∑y2=10\sum y^2 = 10, ∑xy=4+4−1−1=6\sum xy = 4 + 4 - 1 - 1 = 6, so C=(2.51.51.52.5)C = \begin{pmatrix} 2.5 & 1.5 \\ 1.5 & 2.5 \end{pmatrix}. Eigenvalues 44 and 11, with eigenvectors 12(1,1)\frac{1}{\sqrt2}(1, 1) and 12(1,−1)\frac{1}{\sqrt2}(1, -1). The first explains 4/5=80%4/5 = 80\%. Coordinates along 12(1,1)\frac{1}{\sqrt2}(1, 1): 222\sqrt2, −22-2\sqrt2, 00, 00, whose variance (8+8)/4=4(8 + 8)/4 = 4 matches the eigenvalue.

Needs a step first: 28

Learn it with an AI

Copy this prompt into any AI assistant. It will take you through step by step at your level and finish with the test above.

Be my maths tutor. I'm learning "Principal Component Analysis" (Undergraduate II tier): Finding the directions along which data varies most: the top eigenvectors of its covariance matrix, used to compress and visualise data.
I already know: Singular Value Decomposition, Joint Distributions and Covariance.
Teach it Socratically: first ask what I already know; then explain the core idea with one concrete example and why it's true; then give me three problems, one at a time, easy to hard. Wait for my answer, check every step, and point out mistakes without giving the answer away.
Finish by testing me with this: The points $(2, 2)$, $(-2, -2)$, $(1, -1)$, $(-1, 1)$ have mean zero. Using the covariance matrix with divisor $n = 4$, find the principal components, the share of variance the first explains, and each point's coordinate along the first component.
Use LaTeX for formulas. When you say where it's used later (machine learning, quantum mechanics), be specific.

Recommended