David I. Inouye
Dynamic Content · Last Updated: September 11, 2026
Return to the cells described by many measured features.
What reconstruction error are we willing to accept in exchange for fewer features?
We will turn “reconstruct the data well” into a problem involving one matrix.
1. Define what a good reconstruction means — Next
Choose a representation size and measure reconstruction error.
2. Choose a convenient decoder basis.
An orthonormal basis can represent the same reconstruction subspace.
3. Find the best encoder for that decoder.
The closest point in the subspace determines the coordinates.
4. Formulate the subspace choice.
Combine these results into the PCA optimization problem.
For notation simplicity, we now call the raw data \(\widetilde X\) and the centered data \(X\).
\[ \boldsymbol{\mu}=\frac1n\sum_{i=1}^n\widetilde{\boldsymbol{x}}_i, \qquad X=\widetilde X-\boldsymbol{1}_n\boldsymbol{\mu}^T. \]
Add the mean back to reconstruct raw measurements: \(\widehat{\widetilde{\boldsymbol{x}}}_i=\boldsymbol{\mu}+\widehat{\boldsymbol{x}}_i\).
For one centered observation, use the same operator convention as \(\boldsymbol{y}=A\boldsymbol{x}\):
\[ \boldsymbol{z}_i=\underbrace{E}_{k\times d}\boldsymbol{x}_i, \qquad \widehat{\boldsymbol{x}}_i=\underbrace{D}_{d\times k}\boldsymbol{z}_i. \]
Stacking observations as rows gives:
\[ \underbrace{Z}_{n\times k} =\underbrace{X}_{n\times d}\underbrace{E^T}_{d\times k}, \qquad \underbrace{\widehat X}_{n\times d} =\underbrace{Z}_{n\times k}\underbrace{D^T}_{k\times d}. \]
The batch reconstruction is \(\widehat X=XE^TD^T\), with rank at most \(k\).
Choose a linear encoder and decoder to minimize squared reconstruction error:
\[ \min_{E,D}\|X-XE^TD^T\|_F^2. \]
The Frobenius norm measures the error across every entry:
\[ \|M\|_F^2=\sum_{i,j}M_{ij}^2, \qquad \|X-\widehat X\|_F^2 =\sum_{i=1}^n\|\boldsymbol{x}_i-\widehat{\boldsymbol{x}}_i\|_2^2. \]
We have an error measure. Now consider which reconstructions the decoder can produce.
1. Define what a good reconstruction means — Established
Choose a representation size and measure reconstruction error.
2. Choose a convenient decoder basis — Next
An orthonormal basis can represent the same reconstruction subspace.
3. Find the best encoder for that decoder.
The closest point in the subspace determines the coordinates.
4. Formulate the subspace choice.
Combine these results into the PCA optimization problem.
For a \(3\times2\) decoder, the familiar row dot products can be regrouped by column:
\[ \begin{bmatrix}d_{11}&d_{12}\\d_{21}&d_{22}\\d_{31}&d_{32}\end{bmatrix} \begin{bmatrix}z_1\\z_2\end{bmatrix} = \underbrace{\begin{bmatrix}d_{11}z_1+d_{12}z_2\\d_{21}z_1+d_{22}z_2\\d_{31}z_1+d_{32}z_2\end{bmatrix}}_{\text{one dot product per row}} = z_1\underbrace{\begin{bmatrix}d_{11}\\d_{21}\\d_{31}\end{bmatrix}}_{\boldsymbol{d}_1} +z_2\underbrace{\begin{bmatrix}d_{12}\\d_{22}\\d_{32}\end{bmatrix}}_{\boldsymbol{d}_2}. \]
For any number of columns: \(\widehat{\boldsymbol{x}}=D\boldsymbol{z}=\sum_{j=1}^k z_j\boldsymbol{d}_j\).
A line can use a unit vector \(\boldsymbol{u}\) or the scaled vector \(3\boldsymbol{u}\).
\[ \underbrace{\boldsymbol{u}}_{\text{unit basis}}\underbrace{t}_{\text{coordinate}} = \underbrace{(3\boldsymbol{u})}_{\text{scaled basis}}\underbrace{(t/3)}_{\text{adjusted coordinate}}. \]
Both describe the same point on the same line.
Both unit-vector pairs span the plane: either represents every \(\boldsymbol{x}=[x_1,x_2]^T\).
For \(\boldsymbol{b}_1=[1,0]^T\), \(\boldsymbol{b}_2=[1,1]^T/\sqrt2\):
\[ \boldsymbol{x}=(x_1-x_2)\boldsymbol{b}_1+\sqrt2\,x_2\boldsymbol{b}_2. \]
For \(\boldsymbol{w}_1=[1,0]^T\), \(\boldsymbol{w}_2=[0,1]^T\):
\[ \boldsymbol{x}=(\boldsymbol{w}_1^T\boldsymbol{x})\boldsymbol{w}_1 +(\boldsymbol{w}_2^T\boldsymbol{x})\boldsymbol{w}_2. \]
Same plane; simpler coordinates: an orthonormal basis gives each coefficient by a dot product.
Start with any encoder \(E_0\in\mathbb{R}^{k\times d}\) and decoder \(D_0\in\mathbb{R}^{d\times k}\), where \(k\le d\). Suppose \(D_0\) does not have orthonormal columns.
The thin QR decomposition writes \(D_0=WR\): \(W^TW=I_k\) and \(R\) is upper triangular. Here \(W\in\mathbb{R}^{d\times k}\) and \(R\in\mathbb{R}^{k\times k}\).
Can we choose \(D=W\) and a new \(E\) to keep every reconstruction the same?
\(\displaystyle D_0E_0\boldsymbol{x}\)
\(=\)
\(\displaystyle (WR)E_0\boldsymbol{x}\)
(QR of the original decoder)
\(\,\)
\(=\)
\(\displaystyle W(RE_0)\boldsymbol{x}\)
(Regroup the factors)
\(\,\)
\(=\)
\(\displaystyle DE\boldsymbol{x}\)
(Choose \(D=W\), \(E=RE_0\))
Same reconstruction for every input: an orthonormal decoder is without loss of generality. Next, fix \(D=W\) and find its best encoder.
We may choose an orthonormal decoder without changing what we can reconstruct.
1. Define what a good reconstruction means — Established
Choose a representation size and measure reconstruction error.
2. Choose a convenient decoder basis — Established
An orthonormal basis can represent the same reconstruction subspace.
3. Find the best encoder for that decoder — Next
The closest point in the subspace determines the coordinates.
4. Formulate the subspace choice.
Combine these results into the PCA optimization problem.
Any unit \(\boldsymbol{u}\) works. Illustrate with \(\boldsymbol{u}=[1,0]^T\), so \(\boldsymbol{q}=z\boldsymbol{u}=[z,0]^T\).
\(\displaystyle \|\boldsymbol{x}-\boldsymbol{q}\|_2^2\)
\(=\)
\(\displaystyle (x_1-q_1)^2+(x_2-q_2)^2\)
(Squared distance)
\(\,\)
\(=\)
\(\displaystyle (2-z)^2+(2-0)^2\)
(Substitute coordinates)
\(\,\)
\(=\)
\(\displaystyle (2-z)^2+4\)
(Simplify)
Choose \(z=2\): the horizontal error is zero; the height remains.
Fix \(D=W\) with two orthonormal columns spanning this plane. Which point should we reconstruct?
\[ \|\boldsymbol{x}-\boldsymbol{q}\|_2^2 =\underbrace{\|\boldsymbol{x}-\boldsymbol{p}\|_2^2}_{\text{fixed perpendicular error}} +\underbrace{\|\boldsymbol{p}-\boldsymbol{q}\|_2^2}_{\text{extra error within the plane}}. \]
Choose \(\boldsymbol{q}=\boldsymbol{p}\). Moving in either plane direction only adds error.
Recall \(\boldsymbol{u}^T\boldsymbol{x}=\|\boldsymbol{u}\|_2\|\boldsymbol{x}\|_2\cos\theta\). Here \(\|\boldsymbol{u}\|_2=1\).
\(\displaystyle a\)
\(=\)
\(\displaystyle \text{hypotenuse}\,\frac{\text{adjacent}}{\text{hypotenuse}}\)
(\(a\) = adjacent length)
\(\,\)
\(=\)
\(\displaystyle \|\boldsymbol{x}\|_2\cos\theta\)
(Definition of cosine)
\(\,\)
\(=\)
\(\displaystyle \boldsymbol{u}^T\boldsymbol{x}\)
(Dot product; \(\|\boldsymbol{u}\|_2=1\))
The foot is \((\boldsymbol{u}^T\boldsymbol{x})\boldsymbol{u}\). This works in any dimension.
For a plane with orthonormal basis \(\boldsymbol{w}_1,\boldsymbol{w}_2\), read the two signed lengths:
\[ a_1=\boldsymbol{w}_1^T\boldsymbol{x},\qquad a_2=\boldsymbol{w}_2^T\boldsymbol{x}. \]
Combine the corresponding moves within the plane:
\[ \boldsymbol{p}=a_1\boldsymbol{w}_1+a_2\boldsymbol{w}_2 =\begin{bmatrix}\boldsymbol{w}_1&\boldsymbol{w}_2\end{bmatrix} \begin{bmatrix}a_1\\a_2\end{bmatrix}=W\boldsymbol{a}. \]
Next, verify the geometry algebraically: is \(\boldsymbol{x}-\boldsymbol{p}\) perpendicular to every decoder direction?
Fix \(D=W\), with \(W^TW=I_k\). For one centered input, define:
\[ \boldsymbol{a}=W^T\boldsymbol{x},\qquad \boldsymbol{p}=W\boldsymbol{a},\qquad \boldsymbol{r}=\boldsymbol{x}-\boldsymbol{p}. \]
The point \(\boldsymbol{p}\) lies in the decoder’s subspace. Check its residual:
\(\displaystyle W^T\boldsymbol{r}\)
\(=\)
\(\displaystyle W^T(\boldsymbol{x}-W\boldsymbol{a})\)
(Substitute the residual)
\(\displaystyle \,\)
\(=\)
\(\displaystyle W^T\boldsymbol{x}-W^TW\boldsymbol{a}\)
(Distribute)
\(\displaystyle \,\)
\(=\)
\(\displaystyle \boldsymbol{a}-\boldsymbol{a}=\boldsymbol{0}\)
(\(\boldsymbol{a}=W^T\boldsymbol{x}\) and \(W^TW=I_k\))
Each entry is \(\boldsymbol{w}_j^T\boldsymbol{r}=0\): the residual is perpendicular to every basis direction.
For any coordinates \(\boldsymbol{z}\), the decoder returns \(W\boldsymbol{z}\). Insert the perpendicular foot \(\boldsymbol{p}=W\boldsymbol{a}\):
\(\displaystyle \boldsymbol{x}-W\boldsymbol{z}\)
\(=\)
\(\displaystyle (\boldsymbol{x}-\boldsymbol{p})+(\boldsymbol{p}-W\boldsymbol{z})\)
(Add and subtract the same point)
\(\displaystyle \,\)
\(=\)
\(\displaystyle \boldsymbol{r}+(W\boldsymbol{a}-W\boldsymbol{z})\)
(Substitute the two parts)
\(\displaystyle \,\)
\(=\)
\(\displaystyle \boldsymbol{r}+W(\boldsymbol{a}-\boldsymbol{z})\)
(Factor out the decoder)
Changing \(\boldsymbol{z}\) moves only within the subspace, so it cannot cancel \(\boldsymbol{r}\).
Orthonormal columns preserve coordinate lengths: \(\|W\boldsymbol{b}\|_2^2=\boldsymbol{b}^TW^TW\boldsymbol{b}=\|\boldsymbol{b}\|_2^2\).
\(\displaystyle \|\boldsymbol{x}-W\boldsymbol{z}\|_2^2\)
\(=\)
\(\displaystyle \|\boldsymbol{r}+W(\boldsymbol{a}-\boldsymbol{z})\|_2^2\)
(Use the error split)
\(\displaystyle \,\)
\(=\)
\(\displaystyle \|\boldsymbol{r}\|_2^2+\|W(\boldsymbol{a}-\boldsymbol{z})\|_2^2\)
(Pythagoras: the parts are perpendicular)
\(\displaystyle \,\)
\(=\)
\(\displaystyle \|\boldsymbol{r}\|_2^2+\|\boldsymbol{a}-\boldsymbol{z}\|_2^2\)
(Orthonormal columns)
The first term is fixed. The second is nonnegative and becomes zero only at \(\boldsymbol{z}=\boldsymbol{a}=W^T\boldsymbol{x}\).
Therefore \(\widehat{\boldsymbol{x}}=WW^T\boldsymbol{x}\) is the unique closest reconstruction. Write \(P=WW^T\).
We chose the decoder \(D=W\) without loss of generality; minimizing error gives \(E=W^T\).
For the batch of centered observations:
\[ Z=XW,\qquad \widehat X=ZW^T=XWW^T. \]
| Role | Choice | Property |
|---|---|---|
| Encoder | \(E=W^T\in\mathbb{R}^{k\times d}\) | Orthonormal rows: \(EE^T=I_k\). |
| Decoder | \(D=W\in\mathbb{R}^{d\times k}\) | Orthonormal columns: \(D^TD=I_k\). |
Together, these choices attain the best reconstruction error allowed by general \(E,D\).
What remains to choose is the subspace: which \(k\) directions should \(W\) contain?
For a fixed orthonormal decoder, its transpose gives the best encoder. Which subspace should we choose?
1. Define what a good reconstruction means — Established
Choose a representation size and measure reconstruction error.
2. Choose a convenient decoder basis — Established
An orthonormal basis can represent the same reconstruction subspace.
3. Find the best encoder for that decoder — Established
The closest point in the subspace determines the coordinates.
4. Formulate the subspace choice — Next
Combine these results into the PCA optimization problem.
We want \(k\) linear features that reconstruct centered measurements well. Which parts are requirements, and which are convenient parameter choices?
Explain the roles of \(k\), squared error, and \(W^TW=I_k\). Would low reconstruction error alone establish biological usefulness?
\(k\) limits representation size; squared error defines “well.” An orthonormal basis is sufficient for an optimum, but biological usefulness needs more evidence.
For centered data \(X\) and a chosen dimension \(1\le k<d\), PCA solves:
\[ \min_{W\in\mathbb{R}^{d\times k}}\|X-XWW^T\|_F^2 \quad\text{subject to}\quad W^TW=I_k. \]
\[ \underbrace{W^TW=I_k}_{\text{identity in coordinate space}}, \qquad \underbrace{WW^T\ne I_d}_{\text{projection in the original space, since }k<d}. \]
We have formulated PCA using one orthonormal basis \(W\). Now we will solve that problem.
1. Rewrite the objective — Next
Least reconstruction error means most retained squared length.
2. Find the optimal directions
Use the SVD to prove that the leading right singular vectors are optimal.
3. Interpret the solution
Read reconstruction error and coordinate variance from the singular values.
For any orthonormal \(W\), the reconstruction and residual are perpendicular.
\(\displaystyle \|X\|_F^2\)
\(=\)
\(\displaystyle \|XWW^T\|_F^2+\|X-XWW^T\|_F^2\)
(Pythagoras, summed over observations)
\(\,\)
\(=\)
\(\displaystyle \|XW\|_F^2+\|X-XWW^T\|_F^2\)
(\(W\) preserves coordinate lengths)
The data \(X\) are fixed, so
\[ \underbrace{\min_{W^TW=I_k}\|X-XWW^T\|_F^2}_{\text{least reconstruction error}} \quad\Longleftrightarrow\quad \underbrace{\max_{W^TW=I_k}\|XW\|_F^2}_{\text{most retained squared length}}. \]
The total squared length is fixed. We only need to maximize what the coordinates retain.
1. Rewrite the objective — Established
Least reconstruction error means most retained squared length.
2. Find the optimal directions — Next
Use the SVD to prove that the leading right singular vectors are optimal.
3. Interpret the solution
Read reconstruction error and coordinate variance from the singular values.
Now decompose the centered data itself: \(X=U\Sigma V^T\).
\[ X=\sum_{j=1}^{r}\sigma_j\boldsymbol{u}_j\boldsymbol{v}_j^T, \qquad r=\operatorname{rank}(X). \]
| Part | Meaning for the Data Matrix |
|---|---|
| \(\boldsymbol{v}_j\in\mathbb{R}^d\) | One pattern across measured features. |
| \(\sigma_j\boldsymbol{u}_j\in\mathbb{R}^n\) | How strongly that pattern appears in each observation. |
| \(\sigma_j\boldsymbol{u}_j\boldsymbol{v}_j^T\) | A matrix of rank one: one shared pattern with observation-specific weights. |
For \(1\le k\le r\), keeping the leading \(k\) terms gives:
\[ X_k=\sum_{j=1}^{k}\sigma_j\boldsymbol{u}_j\boldsymbol{v}_j^T =U_k\Sigma_kV_k^T. \]
Does this choice retain the most squared length among all \(k\)-dimensional subspaces?
Write \(W=[\boldsymbol{w}_1\ \cdots\ \boldsymbol{w}_k]\) and \(X=U\Sigma V^T\), with \(\sigma_j=0\) for \(j>\operatorname{rank}(X)\).
\(\displaystyle \|XW\|_F^2\)
\(=\)
\(\displaystyle \sum_{\ell=1}^k\|X\boldsymbol{w}_\ell\|_2^2\)
(Sum squared column lengths)
\(\,\)
\(=\)
\(\displaystyle \sum_{\ell=1}^k\sum_{j=1}^d\sigma_j^2(\boldsymbol{v}_j^T\boldsymbol{w}_\ell)^2\)
(\(V^T\) reads coordinates; \(\Sigma\) scales them; \(U\) preserves length)
\(\,\)
\(=\)
\(\displaystyle \sum_{j=1}^d\sigma_j^2\alpha_j\)
(\(\alpha_j=\sum_{\ell=1}^k(\boldsymbol{v}_j^T\boldsymbol{w}_\ell)^2\))
Order \(\sigma_1^2\ge\cdots\ge\sigma_d^2\). We have \(k\) units to allocate, with at most one per direction.
\(\displaystyle \sum_{j=1}^d\sigma_j^2\alpha_j\)
\(\le\)
\(\displaystyle \sum_{j=1}^k\sigma_j^2\alpha_j+\sigma_k^2\left(k-\sum_{j=1}^k\alpha_j\right)\)
(For \(j>k\), \(\sigma_j^2\le\sigma_k^2\))
\(\,\)
\(=\)
\(\displaystyle k\sigma_k^2+\sum_{j=1}^k(\sigma_j^2-\sigma_k^2)\alpha_j\)
(Regroup)
\(\,\)
\(\le\)
\(\displaystyle \sum_{j=1}^k\sigma_j^2\)
(\(\alpha_j\le1\); each coefficient is nonnegative)
\(W=V_k\) attains the bound: \(\alpha_1=\cdots=\alpha_k=1\), all others zero.
\[ Z=XV_k=U_k\Sigma_k,\qquad \widehat X=XV_kV_k^T=X_k. \]
The leading right singular vectors attain the optimum. Now read what this solution keeps and loses.
1. Rewrite the objective — Established
Least reconstruction error means most retained squared length.
2. Find the optimal directions — Established
Use the SVD to prove that the leading right singular vectors are optimal.
3. Interpret the solution — Next
Read reconstruction error and coordinate variance from the singular values.
Subtract the optimal retained squared length from the fixed total:
\[ \|X-X_k\|_F^2=\underbrace{\sum_{j=1}^{r}\sigma_j^2}_{\text{total}}-\underbrace{\sum_{j=1}^{k}\sigma_j^2}_{\text{retained}}=\sum_{j>k}\sigma_j^2. \]
For singular values \(6,3,1\):
| Retained Features | Squared Reconstruction Error |
|---|---|
| \(k=1\) | \(3^2+1^2=10\) |
| \(k=2\) | \(1^2=1\) |
| \(k=3\) | \(0\) |
The \(j\)th coordinate across observations is \(Z_{:j}=X\boldsymbol{v}_j=\sigma_j\boldsymbol{u}_j\). Since \(X\) is centered, this coordinate also has mean zero.
\(\displaystyle \operatorname{Var}_{\mathrm{sample}}(Z_{:j})\)
\(=\)
\(\displaystyle \frac{1}{n-1}\sum_{i=1}^n Z_{ij}^2\)
(Variance of a centered coordinate; \(n>1\))
\(\,\)
\(=\)
\(\displaystyle \frac{\sigma_j^2}{n-1}\|\boldsymbol{u}_j\|_2^2\)
(Substitute \(Z_{:j}=\sigma_j\boldsymbol{u}_j\))
\(\,\)
\(=\)
\(\displaystyle \frac{\sigma_j^2}{n-1}\)
(\(\boldsymbol{u}_j\) is a unit vector)
The leading PCA coordinates therefore have the largest variances. This interprets the solution we already proved.
Original-scale reconstruction: \(\widehat{\widetilde{\boldsymbol{x}}}_i=\boldsymbol{\mu}+W\boldsymbol{z}_i\).
Would one linear feature reconstruct every point exactly? Could a nonlinear coordinate do so? What does “one-dimensional” mean in each claim?
Next: translate this mathematical contract into arrays and reliable numerical computation—then ask what the observed data justify claiming about new cases.