Skip to content

The Maximum Variance Perspective

Page 1001 fixed the code length MM and left the basis open. §10.2 closes it, from one assumption:

If we interpret information content in the data as how “space filling” the dataset is, then we can describe the information contained in the data by looking at the spread of the data.

That is a modelling choice, not a theorem — and it is worth noticing that it is one, because §10.3 will minimise something apparently different and arrive at exactly the same B\mathbf{B}.

  • Equations 10.7–10.9b: how “maximise the variance of the code” collapses to b1Sb1\mathbf{b}_1^\top\mathbf{S}\mathbf{b}_1 — one Chapter 6 identity and one line of algebra. Measured, all three readings agree to 8.5×10148.5\times10^{-14}.
  • Why the constraint b12=1\lVert\mathbf{b}_1\rVert^2 = 1 is not cosmetic: without it the objective has no maximum at all.
  • Equations 10.11–10.14: the Lagrangian, and the moment Sb1=λ1b1\mathbf{S}\mathbf{b}_1 = \lambda_1\mathbf{b}_1 appears — “the Lagrange multiplier plays the role of the corresponding eigenvalue.”
  • Equation 10.15, V1=λ1V_1 = \lambda_1 — measured for the first six components, largest gap 8.5×10148.5\times10^{-14}. The variance you keep is the eigenvalue; there is nothing else to compute.
  • Equation 10.17’s deflation and Equation 10.21’s claim that S\mathbf{S} and S^\hat{\mathbf{S}} share eigenvectors — verified by deflating four times and recovering each bm\mathbf{b}_m to under 2.1×1062.1\times10^{-6} degrees.
  • Equations 10.24 and 10.25: VM=mMλmV_M = \sum_{m\le M}\lambda_m and JM=j>MλjJ_M = \sum_{j>M}\lambda_j, and the fact that the measured reconstruction error matches JMJ_M to 2.8×10132.8\times10^{-13} — a result §10.3 will spend a whole section deriving.
  • Why a random search is hopeless in 6464 dimensions: 200,000200{,}000 random unit vectors reach 37.18%37.18\% of λ1\lambda_1, while power iteration reaches it in 500500 cheap steps.

Intuition: the objective is a function on a circle

Section titled “Intuition: the objective is a function on a circle”

Strip §10.2 to two dimensions and the whole argument fits in one picture. A unit vector in the plane is just an angle. Feed it to bSb\mathbf{b}^\top\mathbf{S}\mathbf{b} and you get a number. Sweep the angle and you get a curve — and the curve has a maximum somewhere.

figure Equation 10.10 is a search over directions, and the answer is an eigenvector matplotlib
Top left, a smooth wave over direction angle from zero to one hundred eighty degrees, peaking near thirty-three degrees at a dashed amber line and bottoming near one hundred twenty-three degrees at a dashed green line. Top right, a tilted elliptical point cloud with three coloured lines through it at those angles. Bottom, three histograms of the projected coordinate, visibly widest for the amber direction and narrowest for the red one. Top left, a smooth wave over direction angle from zero to one hundred eighty degrees, peaking near thirty-three degrees at a dashed amber line and bottoming near one hundred twenty-three degrees at a dashed green line. Top right, a tilted elliptical point cloud with three coloured lines through it at those angles. Bottom, three histograms of the projected coordinate, visibly widest for the amber direction and narrowest for the red one.
The top-left curve is the objective. Its maximum is exactly the largest eigenvalue and its minimum exactly the smallest — for a symmetric S those are the only two stationary points on the circle. The bottom row is the same three numbers as spread: the amber projection is the fattest histogram, the red the thinnest.

Two things the picture makes obvious that the algebra hides:

The curve is smooth and has exactly two stationary points on the half-circle — one maximum, one minimum. Those are the two eigenvectors. In DD dimensions there are DD of them, which is why one eigendecomposition answers the question for every MM at once.

You cannot find the peak by sampling. In two dimensions you could. In 6464 dimensions the surface of the unit sphere is overwhelmingly far from any particular direction: measured below, 200,000200{,}000 random unit vectors get to 37.18%37.18\% of the maximum.

§10.2.1 From “spread” to an eigenvalue problem

Section titled “§10.2.1 From “spread” to an eigenvalue problem”

The variance of the first coordinate of the code, using the i.i.d. assumption:

V1:=V[z1]=1Nn=1Nz1n2,z1n=b1xn(10.7), (10.8)V_1 := \mathbb{V}[z_1] = \frac{1}{N}\sum_{n=1}^{N} z_{1n}^2, \qquad z_{1n} = \mathbf{b}_1^\top\mathbf{x}_n \qquad \text{(10.7), (10.8)}

Substituting and using the symmetry of the dot product, b1xn=xnb1\mathbf{b}_1^\top\mathbf{x}_n = \mathbf{x}_n^\top\mathbf{b}_1:

V1=1Nn=1Nb1xnxnb1=b1 ⁣(1Nn=1Nxnxn) ⁣b1=b1Sb1(10.9a), (10.9b)V_1 = \frac{1}{N}\sum_{n=1}^{N}\mathbf{b}_1^\top\mathbf{x}_n\mathbf{x}_n^\top\mathbf{b}_1 = \mathbf{b}_1^\top\!\left(\frac{1}{N}\sum_{n=1}^{N}\mathbf{x}_n\mathbf{x}_n^\top\right)\!\mathbf{b}_1 = \mathbf{b}_1^\top\mathbf{S}\mathbf{b}_1 \qquad \text{(10.9a), (10.9b)}

The only move is pulling b1\mathbf{b}_1 outside the sum, which is legal because it does not depend on nn. Measured on the digit-”8” data, three routes to the same number:

routevalue
1Nnz1n2\frac{1}{N}\sum_n z_{1n}^2, Equation 10.7151.568412151.568412
b1Sb1\mathbf{b}_1^\top\mathbf{S}\mathbf{b}_1, Equation 10.9b151.568412151.568412
np.var of the code151.568412151.568412
λ1\lambda_1, Equation 10.15151.568412151.568412
largest gap between any two8.5×10148.5\times10^{-14}

(The code’s mean comes out at 2.5×10162.5\times10^{-16}, so Equation 10.7’s “mean of the squares” really is the variance, as the book’s centred-data remark promises.)

“Arbitrarily increasing the magnitude of the vector b1\mathbf{b}_1 increases V1V_1 — doubling b1\mathbf{b}_1 quadruples b1Sb1\mathbf{b}_1^\top\mathbf{S}\mathbf{b}_1. So the unconstrained problem has a supremum of ++\infty and no maximiser. Restricting to b12=1\lVert\mathbf{b}_1\rVert^2 = 1 gives

maxb1 b1Sb1subject tob12=1(10.10)\max_{\mathbf{b}_1}\ \mathbf{b}_1^\top\mathbf{S}\mathbf{b}_1 \quad\text{subject to}\quad \lVert\mathbf{b}_1\rVert^2 = 1 \qquad \text{(10.10)}

and Chapter 7’s Lagrangian

L(b1,λ)=b1Sb1+λ1 ⁣(1b1b1)(10.11)\mathfrak{L}(\mathbf{b}_1, \lambda) = \mathbf{b}_1^\top\mathbf{S}\mathbf{b}_1 + \lambda_1\!\left(1 - \mathbf{b}_1^\top\mathbf{b}_1\right) \qquad \text{(10.11)} Lb1=2b1S2λ1b1,Lλ1=1b1b1(10.12)\frac{\partial\mathfrak{L}}{\partial\mathbf{b}_1} = 2\mathbf{b}_1^\top\mathbf{S} - 2\lambda_1\mathbf{b}_1^\top, \qquad \frac{\partial\mathfrak{L}}{\partial\lambda_1} = 1 - \mathbf{b}_1^\top\mathbf{b}_1 \qquad \text{(10.12)}

Setting both to 0\mathbf{0}:

Sb1=λ1b1,b1b1=1(10.13), (10.14)\mathbf{S}\mathbf{b}_1 = \lambda_1\mathbf{b}_1, \qquad \mathbf{b}_1^\top\mathbf{b}_1 = 1 \qquad \text{(10.13), (10.14)}

“By comparing this with the definition of an eigenvalue decomposition, we see that b1\mathbf{b}_1 is an eigenvector of the data covariance matrix S\mathbf{S}, and the Lagrange multiplier λ1\lambda_1 plays the role of the corresponding eigenvalue.” Measured — the gradient 2Sb2λ1b2\mathbf{S}\mathbf{b} - 2\lambda_1\mathbf{b} at three unit vectors:

unit vector, with λ=λ1\lambda = \lambda_1\lVertgradient\rVert
b1\mathbf{b}_10.000000\mathbf{0.000000}
b2\mathbf{b}_2127.709219127.709219
a random direction (seed 00)285.800195285.800195

Because Sb1=λ1b1\mathbf{S}\mathbf{b}_1 = \lambda_1\mathbf{b}_1 and b1b1=1\mathbf{b}_1^\top\mathbf{b}_1 = 1:

V1=b1Sb1=λ1b1b1=λ1(10.15)V_1 = \mathbf{b}_1^\top\mathbf{S}\mathbf{b}_1 = \lambda_1\mathbf{b}_1^\top\mathbf{b}_1 = \lambda_1 \qquad \text{(10.15)}
mmbmSbm\mathbf{b}_m^\top\mathbf{S}\mathbf{b}_mλm\lambda_mgap
11151.56841162151.56841162151.56841162151.568411628.5×10148.5\times10^{-14}
2287.7138021487.7138021487.7138021487.713802145.7×10145.7\times10^{-14}
3375.2849472275.2849472275.2849472275.284947221.4×10141.4\times10^{-14}
4454.0551309054.0551309054.0551309054.055130907.1×10157.1\times10^{-15}
5552.4132110952.4132110952.4132110952.413211093.6×10143.6\times10^{-14}
6642.5774252942.5774252942.5774252942.577425290.00.0

The eigendecomposition does not just tell you where to look — it tells you what you will find there. No projection needs to be formed to know how much variance a component keeps. The book’s margin note adds the name: λ1\sqrt{\lambda_1} is the loading of b1\mathbf{b}_1, the standard deviation accounted for by span[b1]\mathrm{span}[\mathbf{b}_1].

§10.2.2 The second component, and why there is nothing new to do

Section titled “§10.2.2 The second component, and why there is nothing new to do”

For bm\mathbf{b}_m with m>1m > 1, the book’s device is to remove what the earlier components already explain:

X^:=Xi=1m1bibiX=XBm1X(10.17)\hat{\mathbf{X}} := \mathbf{X} - \sum_{i=1}^{m-1}\mathbf{b}_i\mathbf{b}_i^\top\mathbf{X} = \mathbf{X} - \mathbf{B}_{m-1}\mathbf{X} \qquad \text{(10.17)}

then maximise Vm=bmS^bmV_m = \mathbf{b}_m^\top\hat{\mathbf{S}}\mathbf{b}_m against the deflated covariance, which is the §10.2.1 problem again. Run literally — deflate, re-decompose, take the top eigenvector, repeat:

mmtop eigenvalue of S^\hat{\mathbf{S}}λm\lambda_m of S\mathbf{S}angle to bm\mathbf{b}_m
11151.568412151.568412151.568412151.5684121.7×1061.7\times10^{-6} deg
2287.71380287.71380287.71380287.7138022.1×1062.1\times10^{-6} deg
3375.28494775.28494775.28494775.2849471.2×1061.2\times10^{-6} deg
4454.05513154.05513154.05513154.0551310.00.0 deg
5552.41321152.41321152.41321152.4132110.00.0 deg

The book proves this must happen. Split the eigenvectors of S\mathbf{S} by whether they have been used:

Bm1bi=bi  if i<m,Bm1bi=0  if im(10.20)\mathbf{B}_{m-1}\mathbf{b}_i = \mathbf{b}_i \ \ \text{if } i < m, \qquad \mathbf{B}_{m-1}\mathbf{b}_i = \mathbf{0} \ \ \text{if } i \geq m \qquad \text{(10.20)}

Expanding S^=SSBm1Bm1S+Bm1SBm1\hat{\mathbf{S}} = \mathbf{S} - \mathbf{S}\mathbf{B}_{m-1} - \mathbf{B}_{m-1}\mathbf{S} + \mathbf{B}_{m-1}\mathbf{S}\mathbf{B}_{m-1} and applying each case gives

S^bm=Sbm=λmbm(10.21)\hat{\mathbf{S}}\mathbf{b}_m = \mathbf{S}\mathbf{b}_m = \lambda_m\mathbf{b}_m \qquad \text{(10.21)} S^bi=0=0bifor i<m(10.22)\hat{\mathbf{S}}\mathbf{b}_i = \mathbf{0} = 0\,\mathbf{b}_i \quad\text{for } i < m \qquad \text{(10.22)}
figure Deflating removes one eigenvalue and leaves every other one alone matplotlib
Left, four descending eigenvalue curves; each successive curve starts one step lower, so the four lines are the same sequence shifted left by zero, one, two and three places. Right, a log-scale bar chart of six values: the first three sit at about 1e-14 and the last three at about 50. Left, four descending eigenvalue curves; each successive curve starts one step lower, so the four lines are the same sequence shifted left by zero, one, two and three places. Right, a log-scale bar chart of six values: the first three sit at about 1e-14 and the last three at about 50.
Left: after removing m components, the deflated spectrum is the original one with its first m entries deleted — the curves overlay exactly, measured to 7.8e-14. Right: the three used-up directions become null vectors of S-hat, with residual norms 1.0e-14, 5.9e-15 and 7.1e-15 against roughly 50 for the untouched ones.

With Equation 10.21 in hand, Vm=bmSbm=λmV_m = \mathbf{b}_m^\top\mathbf{S}\mathbf{b}_m = \lambda_m for every mm (Equation 10.23), and summing:

VM=m=1Mλm,JM:=j=M+1Dλj=VDVM(10.24), (10.25)V_M = \sum_{m=1}^{M}\lambda_m, \qquad J_M := \sum_{j=M+1}^{D}\lambda_j = V_D - V_M \qquad \text{(10.24), (10.25)}

Example 10.2, and the number the next section has to derive

Section titled “Example 10.2, and the number the next section has to derive”
figure The spectrum of the digit-8 covariance, and what it costs to keep most of it matplotlib
Left, sixty-four eigenvalues plotted on a log scale, falling smoothly from about 150 to near one, then collapsing off the bottom of the plot after index fifty-two. Right, a cumulative captured-variance curve rising steeply then flattening, with marked crossings at fifty percent, ninety percent and ninety-nine percent. Left, sixty-four eigenvalues plotted on a log scale, falling smoothly from about 150 to near one, then collapsing off the bottom of the plot after index fifty-two. Right, a cumulative captured-variance curve rising steeply then flattening, with marked crossings at fifty percent, ninety percent and ninety-nine percent.
The variance is heavily concentrated: one component of sixty-four holds 20.45 percent of it, and eighteen hold ninety percent. The cliff after index fifty-two is page 1001's twelve dead border pixels — twelve directions along which every image is identical, so their eigenvalues fall to machine zero.
MMVMV_M (Eq 10.24)JMJ_M (Eq 10.25)share keptmeasured 1Nxnx~n2\frac{1}{N}\sum\lVert\mathbf{x}_n-\tilde{\mathbf{x}}_n\rVert^2
11151.568412151.568412589.590460589.59046020.45%20.45\%589.590460589.590460
22239.282214239.282214501.876658501.87665832.28%32.28\%501.876658501.876658
55421.035503421.035503320.123369320.12336956.81%56.81\%320.123369320.123369
1010574.968069574.968069166.190803166.19080377.58%77.58\%166.190803166.190803
2020681.807067681.80706759.35180559.35180591.99%91.99\%59.35180559.351805
3030722.255016722.25501618.90385618.90385697.45%97.45\%18.90385618.903856
5252741.158872741.1588720.0000000.000000100.00%100.00\%0.0000000.000000

The last column was never mentioned in §10.2. It is the average squared reconstruction error, formed by actually building X~=BBX\tilde{\mathbf{X}} = \mathbf{B}\mathbf{B}^\top\mathbf{X} and measuring — and across every MM from 11 to 6363 it agrees with JMJ_M to 2.8×10132.8\times10^{-13}.

That equality is §10.3’s entire result, arrived at here for free. §10.2 maximised the variance kept; the error paid came out as the leftover eigenvalues without anyone asking. §10.3 turns the observation into a derivation, and Equation 10.44 will state it.

variance retainedcomponents neededshare of the 6464 dimensions
50%50\%M=5M = 57.8%7.8\%
80%80\%M=12M = 1218.8%18.8\%
90%90\%M=18M = 1828.1%28.1\%
95%95\%M=25M = 2539.1%39.1\%
99%99\%M=36M = 3656.2%56.2\%
pch.quizTag Does the variance argument hold together?
  1. Why does Equation 10.10 constrain b to have unit norm?

    pch.quizShowAnswer

    B — Because without it the objective is unbounded — doubling b quadruples b-transpose S b, so there is no maximiser at all — The book says it plainly: arbitrarily increasing the magnitude of b increases V1. The supremum of the unconstrained problem is infinity and no vector attains it. The constraint turns a meaningless problem into the one Chapter 7's Lagrangian solves, and the multiplier that appears turns out to be the eigenvalue.

  2. Equation 10.15 says V1 equals lambda-1. What is the practical consequence?

    pch.quizShowAnswer

    B — The eigendecomposition already tells you the variance each component keeps — no projection needed — Measured for the first six components of the digit-8 covariance, b-transpose S b matches lambda to at worst 8.5e-14. One sorted list of eigenvalues prices every possible choice of M: V_M is the running sum and J_M is what is left, and the measured reconstruction error matches J_M to 2.8e-13.

  3. What does Equation 10.21 establish about the deflated covariance S-hat?

    pch.quizShowAnswer

    B — S and S-hat share eigenvectors; the used-up ones simply acquire eigenvalue zero — Measured: deflating three times leaves S-hat b1, b2 and b3 with norms 1.0e-14, 5.9e-15 and 7.1e-15 — they are null vectors now — while the remaining eigenvalues match those of S to 7.8e-14. So the sequential search returns the eigenvectors of the ORIGINAL S, which one eigendecomposition already produced. Equation 10.17 is a proof device.

  4. Why is random search a bad way to find the direction of maximum variance?

    pch.quizShowAnswer

    B — In 64 dimensions the unit sphere is too large — 200,000 random unit vectors reached only 37.18 percent of lambda-1 — Measured on the digit-8 covariance: the best of 200,000 random unit vectors scored 56.351776 against lambda-1 of 151.568412. Power iteration — repeatedly multiply by S and renormalise, Equation 10.52 — reaches the exact answer in 500 steps, landing 1.2e-06 degrees from b1.

Exercise 1 – Three ways to say the same variance

Section titled “Exercise 1 – Three ways to say the same variance”

Exercise 2 – The Lagrangian’s gradient, and where it vanishes

Section titled “Exercise 2 – The Lagrangian’s gradient, and where it vanishes”

Exercise 3 – Is lambda-1 really the maximum?

Section titled “Exercise 3 – Is lambda-1 really the maximum?”

Exercise 4 – Deflate, and watch the eigenvalues not move

Section titled “Exercise 4 – Deflate, and watch the eigenvalues not move”

Exercise 5 – Equation 10.25 predicts an error nobody measured yet

Section titled “Exercise 5 – Equation 10.25 predicts an error nobody measured yet”
  • Section 10.2 assumes that information is spread, and derives PCA by maximising the variance of the code. That is a modelling choice, and Section 10.3 reaches the same answer from a different one.
  • Equation 10.9b turns the objective into b-transpose S b in one line, using only the symmetry of the dot product. Measured three ways on the digit-8 data, all agreeing to 8.5e-14.
  • The unit-norm constraint is load-bearing: doubling b quadruples the objective, so without it there is no maximum at all.
  • The Lagrangian’s stationarity condition is the eigenvalue equation. Measured, the gradient is exactly zero at the leading eigenvector and 127.709219 at the second.
  • Equation 10.15: the variance kept equals the eigenvalue. So one sorted eigenvalue list prices every possible choice of M, with no projection formed.
  • Two hundred thousand random unit vectors in 64 dimensions reach 37.18 percent of the largest eigenvalue. Power iteration reaches it exactly in 500 steps.
  • Equation 10.17’s deflation is a proof device, not an algorithm. S and the deflated S-hat share eigenvectors; the used-up ones simply acquire eigenvalue zero, measured at about 1e-14.
  • So the greedy sequential choice is genuinely optimal, not merely locally optimal — the m-th round returns the m-th eigenvector of the original S.
  • Equations 10.24 and 10.25 split the total variance into what is kept and what is lost, and the two always sum to the trace.
  • The lost part equals the measured reconstruction error, to 2.8e-13, even though Section 10.2 never mentioned reconstruction. Section 10.3 derives that.
  • On 174 images of the digit eight, half the variance costs 5 components and ninety-nine percent costs 36. Twelve eigenvalues are machine zero — the dead border pixels, free to discard.

Next: The Projection Perspective — the same B\mathbf{B}, derived by minimising the reconstruction error instead, starting with the coordinates rather than the basis.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading