ES98A · Course contents

ES98A · Week 2

Week 2: Least squares meets probability: normal equations + multivariate distributions

The Week 1 fit had one adjustable direction. What if a model has many parameters, some of which barely change the observations? We need coordinates that separate what the experiment measures strongly, weakly and not at all.

The SVD supplies those coordinates. It also exposes a distinction that will guide the rest of the course: a best prediction can be unique even when its parameters are not, and a unique parameter estimate can still be unreliable. Probability then gives us a language for the uncertainty that a deterministic error bound cannot describe.

Topics


Matrix factorisations (continued)

Recap: eigenvalues/eigenvectors for Hermitian matrices

Eigenvalue problem: given A∈Cn×nA\in\mathbb{C}^{n\times n}, find λ∈C\lambda\in\mathbb{C} and q∈Cnq\in\mathbb{C}^n such that

Aq=λq,∣q∣=1.Aq=\lambda q, \qquad |q|=1.

If AA is Hermitian/self-adjoint (A=A∗A=A^*), then:

⟨qi,qj⟩=δij={1i=j0i≠j\langle q_i,q_j\rangle=\delta_{ij}= \begin{cases} 1 & i=j\\ 0 & i\ne j \end{cases} Q∗Q=I,A=QΛQ∗.Q^*Q=I, \qquad A=Q\Lambda Q^*.

Using outer products:

A=∑i=1nλi (qi⊗qi).A=\sum_{i=1}^n \lambda_i\,(q_i\otimes q_i).

Recall: for vectors a,ba,b, the outer product acts by

(a⊗b)c=⟨a,c⟩ b.(a\otimes b)c=\langle a,c\rangle\,b.

The singular value decomposition (SVD)

An eigenbasis uses the same space for inputs and outputs. A rectangular map has no reason to permit that: its input and output dimensions may differ. Instead, seek paired unit directions satisfying Avi=σiuiAv_i=\sigma_i u_i. Measuring an input along viv_i produces an output along uiu_i, scaled by σi\sigma_i. This is Week 1's “measure then reconstruct” operation with different rulers on each side.

Theorem (SVD)

Let A∈Km×nA\in\mathbb{K}^{m\times n} (with K=R\mathbb{K}=\mathbb{R} or C\mathbb{C}). Then there exist unitary matrices

U∈Km×m,V∈Kn×n,U\in\mathbb{K}^{m\times m}, \qquad V\in\mathbb{K}^{n\times n},

and a diagonal (rectangular) matrix Σ∈Rm×n\Sigma\in\mathbb{R}^{m\times n} with diagonal entries

σ1≥σ2≥⋯≥0\sigma_1\ge\sigma_2\ge\cdots\ge 0

(and zeros off-diagonal) such that

A=UΣV∗.A=U\Sigma V^*.

Equivalently: there exist orthonormal bases u1,…,umu_1,\dots,u_m of Km\mathbb{K}^m and v1,…,vnv_1,\dots,v_n of Kn\mathbb{K}^n and nonnegative numbers σ1,…,σr\sigma_1,\dots,\sigma_r (where r=rank(A)r=\mathrm{rank}(A)) such that

A=∑i=1rσi (vi⊗ui).A=\sum_{i=1}^r \sigma_i\,(v_i\otimes u_i).

Action on a vector x∈Knx\in\mathbb{K}^n:

Ax=∑i=1rσi (vi⊗ui)x=∑i=1rσi ui⟨vi,x⟩=∑i=1rσi uivi∗x.Ax=\sum_{i=1}^r \sigma_i\,(v_i\otimes u_i)x = \sum_{i=1}^r \sigma_i\,u_i\langle v_i,x\rangle = \sum_{i=1}^r \sigma_i\,u_i v_i^*x.

Why these directions exist

Diagonalise the SPSD matrix A∗AA^*A. If A∗Avi=σi2viA^*Av_i=\sigma_i^2v_i with σi>0\sigma_i>0, set ui=Avi/σiu_i=Av_i/\sigma_i. Then

⟨ui,uj⟩=⟨vi,A∗Avj⟩σiσj=δij.\langle u_i,u_j\rangle=\frac{\langle v_i,A^*Av_j\rangle}{\sigma_i\sigma_j}=\delta_{ij}.

Zero-eigenvalue input directions form ker⁡A\ker A; complete the output directions to an ONB. Applying AA to the expansion of an arbitrary input proves the displayed decomposition. In particular A∗ui=σiviA^*u_i=\sigma_i v_i. The same singular value describes a forward measurement and its adjoint.

Remarks

Select a factor to follow the same operation in the explanation.

Ax = ∑ᵢ

Project x onto the input direction vᵢ, scale that coordinate by σᵢ, then reconstruct along the output direction uᵢ. The sum combines all nonzero singular modes.

  1. The leading singular value is the operator norm:
σ1=∣A∣op:=max⁡∣x∣=1∣Ax∣=max⁡x≠0∣Ax∣∣x∣.\sigma_1=|A|_{\mathrm{op}}:=\max_{|x|=1}|Ax|=\max_{x\ne 0}\frac{|Ax|}{|x|}.
  1. Truncating the SVD gives a rank-pp approximation ("truncated SVD", related to PCA):
A≈A(p):=∑i=1pσi (vi⊗ui).A\approx A_{(p)}:=\sum_{i=1}^p \sigma_i\,(v_i\otimes u_i).
  1. Later: compact operators will have an SVD with infinitely many terms and σi→0\sigma_i\to 0 as i→∞i\to\infty.

  2. The SVD gives a generalised inverse (pseudoinverse) A†∈Kn×mA^\dagger\in\mathbb{K}^{n\times m} of

A=∑i=1rσi (vi⊗ui)A=\sum_{i=1}^r \sigma_i\,(v_i\otimes u_i)

via

A†=∑i=1r1σi (ui⊗vi),σi≠0 for i≤r.A^\dagger=\sum_{i=1}^r \frac{1}{\sigma_i}\,(u_i\otimes v_i), \qquad \sigma_i\ne 0\ \text{for }i\le r.

The reciprocal singular values increase in this indexing. Reordering the paired directions gives the conventional decreasing order for an SVD of the pseudoinverse.

The factorisation is a sequence of operations on the same points. Play it slowly: first change input coordinates, then scale, then choose output coordinates. The two spaces need not share their singular directions.

Read, scale, reconstruct

Input unit circle

-1.801.8-1.801.8input x₁input x₂

Transform the same points

-1.801.8-1.801.8current first coordinatecurrent second coordinate

1. V* reads the input in the singular basis

Track the solid first basis edge and dashed reference circle. Rotation alone preserves lengths; unequal scaling creates the ellipse.

Play once, pause, or scrub to inspect an intermediate state.

Ready to explore.
A=R(35°) diag(1.4,0.5) R(−25°). First rotate into input coordinates, then stretch, then rotate into output coordinates. Intermediate maps interpolate each operation; only the endpoint is A. ↗

Exercises (from the notes)

Let A=∑i=1rσi (vi⊗ui)A=\sum_{i=1}^r \sigma_i\,(v_i\otimes u_i) be an SVD. Show:

A∗=∑i=1rσi (ui⊗vi),A∗A=∑i=1rσi2 (vi⊗vi).A^*=\sum_{i=1}^r \sigma_i\,(u_i\otimes v_i), \qquad A^*A=\sum_{i=1}^r \sigma_i^2\,(v_i\otimes v_i).

What is AA∗AA^*?


Least squares and normal equations

Given A∈Km×nA\in\mathbb{K}^{m\times n} and b∈Kmb\in\mathbb{K}^m, consider the least squares problem: find x∈Knx\in\mathbb{K}^n minimising

Φ(x):=12∣Ax−b∣2=12∑j=1m∣(Ax)j−bj∣2.\Phi(x):=\frac{1}{2}|Ax-b|^2 =\frac{1}{2}\sum_{j=1}^m |(Ax)_j-b_j|^2.

Over the real numbers, differentiate the squared residual. Over the complex numbers, regard the domain as a real vector space with metric Re⁡⟨⋅,⋅angle\operatorname{Re}\langle\cdot,\cdot angle; the same gradient expression holds:

∇Φ(x)=A∗Ax−A∗b.\nabla \Phi(x)=A^*Ax-A^*b.

Hessian/second derivative (constant in xx):

∇2Φ(x)=A∗A,\nabla^2\Phi(x)=A^*A,

and A∗AA^*A is SPSD.

Therefore, minimisers are precisely the solutions of the normal equations:

A∗Ax=A∗b.A^*Ax=A^*b.

Special case: if AA has full column rank, then A∗AA^*A is invertible and the minimiser is unique:

x†:=(A∗A)−1A∗b.x^\dagger:=(A^*A)^{-1}A^*b.

A nontrivial kernel removes uniqueness of the parameters, while leaving the best predicted vector unique.

If AA has SVD A=∑i=1rσi (vi⊗ui)A=\sum_{i=1}^r \sigma_i\,(v_i\otimes u_i), then (using the exercise identities)

x†=(A∗A)−1A∗b=∑i=1r1σi (ui⊗vi)b,x^\dagger=(A^*A)^{-1}A^*b=\sum_{i=1}^r \frac{1}{\sigma_i}\,(u_i\otimes v_i)b,

i.e.

x†=A†b.x^\dagger=A^\dagger b.

The normal equations are also the perpendicular-residual condition from Week 1: A∗(Ax−b)=0A^*(Ax-b)=0 says that the residual is orthogonal to every attainable prediction. For any minimiser x0x_0 and increment hh,

∣A(x0+h)−b∣2=∣Ax0−b∣2+∣Ah∣2.|A(x_0+h)-b|^2=|Ax_0-b|^2+|Ah|^2.

Thus every minimiser is A†b+zA^\dagger b+z with z∈ker⁡Az\in\ker A. Since A†b⊥ker⁡AA^\dagger b\perp\ker A, it uniquely minimises parameter norm. The inverse (A∗A)−1(A^*A)^{-1} in the preceding formula is available only at full column rank; the singular expansion remains valid at any rank.

Numerical interpretation. For full column rank, κ2(A∗A)=κ2(A)2\kappa_2(A^*A)=\kappa_2(A)^2. Normal equations explain the geometry beautifully, but QR or SVD avoids explicitly squaring the condition number when computing sensitive fits.

Stability note

The inverse formula above assumes full column rank. The pseudoinverse itself is defined for rank-deficient matrices as well; it selects the minimum-norm least-squares solution.

Before reading the bounds, consider which data perturbations the inverse amplifies most in Figure 1.

Equal data errors, unequal reconstruction errors
For A = diag(1, 0.2), which perturbation of length 0.1 causes the larger reconstruction error?
Data perturbation δb0.120.12u₁u₂(0.071, 0.071)Reconstruction error A†δb2.12.1v₁v₂(0.071, 0.354)

Error norm: 0.361. Upper bound 0.1 / σ₂: 0.500.

1. Resolve the data error

δb = 0.1(cos θ u₁ + sin θ u₂). Its length remains 0.1.

Figure 1. A real two-dimensional teaching model: A = diag(1, σ₂), U = V = I. Rotate a data perturbation of fixed length 0.1; then reduce σ₂. The dashed circle and ellipse show all possible endpoints. The panels use different, fixed scales: ±0.12 and ±2.1. ↗

Forward map is stable:

∣A(x+δx)−Ax∣=∣A(δx)∣≤∣A∣op∣δx∣=σ1∣δx∣.|A(x+\delta x)-Ax|=|A(\delta x)|\le |A|_{\mathrm{op}}|\delta x|=\sigma_1|\delta x|.

For rank r>0r>0, the inverse map can be sensitive:

∣A†(b+δb)−A†b∣=∣A†(δb)∣≤∣A†∣op∣δb∣=1σr∣δb∣.|A^\dagger(b+\delta b)-A^\dagger b| =|A^\dagger(\delta b)| \le |A^\dagger|_{\mathrm{op}}|\delta b| =\frac{1}{\sigma_r}|\delta b|.

The constant σr−1\sigma_r^{-1} can be huge; reconstructions A†bA^\dagger b are sensitive to perturbations in bb parallel to singular vectors uiu_i corresponding to small σi\sigma_i.

At fixed finite rank the pseudoinverse is bounded, but its norm may be enormous. Infinite-dimensional compact inverses in Week 8 can be unbounded: sensitivity then becomes ill-posedness in the continuity sense. For the zero matrix, the pseudoinverse is zero and the positive-singular-value bound is unnecessary.


Hold the amount of observation noise fixed and let just one singular value shrink. The evolving ellipse isolates why a small forward response can produce a large inverse error.

A weak measurement becomes a large inverse error

Fixed observation noise

-1.101.1-1.101.1noise coordinate 1noise coordinate 2

Error after inversion

-1.101.1-1.101.1error coordinate 1error coordinate 2

σ₂=1.000, max error=0.1/σ₂=0.100

The first inverse direction is unchanged. The weak second measurement stretches the same noise into a long reconstruction-error ellipse.

Play once, pause, or scrub to inspect an intermediate state.

Ready to explore.
Fixed data noise has length 0.1. A=diag(1,σ₂), with σ₂ decreasing from 1 to 0.1. The error ellipse has semiaxes 0.1 and 0.1/σ₂. All axis scales remain fixed; zero is excluded. ↗

Probability (finite-dimensional)

A bound such as ∣δx∣≤∣δb∣/σr|\delta x|\le |\delta b|/\sigma_r protects against the worst direction. It does not say how often that direction occurs. To ask about typical errors or uncertainty in a parameter, we must specify which outcomes are possible and how much probability they receive. A probability space makes those choices explicit.

Kolmogorov setup

  1. A non-empty set Ω\Omega (sample space/outcome space).

  2. A collection of measurable events F⊆P(Ω)\mathcal{F}\subseteq \mathcal{P}(\Omega), required to be a σ\sigma-algebra:

(Annotation: F\mathcal{F} is like a list of questions it is "ok" to ask about the outcome ω∈Ω\omega\in\Omega; if E∈FE\in\mathcal{F} you may ask whether ω∈E\omega\in E.)

  1. A probability measure P:F→[0,1]\mathbb{P}:\mathcal{F}\to [0,1] such that:
P ⁣(⨆n∈NEn)=∑n∈NP(En).\mathbb{P}\!\left(\bigsqcup_{n\in\mathbb{N}}E_n\right)=\sum_{n\in\mathbb{N}}\mathbb{P}(E_n).

Interpretations of probability

Two main meanings of P(E)\mathbb{P}(E):

  1. Frequentist: idealised replicable experiment; on each run EE happens or not; under iid replication, the strong law gives
P(E)=lim⁡n→∞Number of times E occurs in first n trialsn\mathbb{P}(E)=\lim_{n\to\infty}\frac{\text{Number of times }E\text{ occurs in first }n\text{ trials}}{n}
  1. Bayesian/subjectivist: can speak of probability of any statement EE, using probabilities to express degrees of belief. Probability one means almost sure, not logical necessity: a specified point in a continuous distribution has probability zero without being impossible.

Aleatoric vs epistemic uncertainty

Bayes' formula (events)

For A,B∈FA,B\in\mathcal{F} with P(A)>0\mathbb{P}(A)>0 and P(B)>0\mathbb{P}(B)>0, define conditional probability

P(A∣B):=P(A∩B)P(B).\mathbb{P}(A\mid B):=\frac{\mathbb{P}(A\cap B)}{\mathbb{P}(B)}.

Then

P(B∣A)P(A)=P(A∩B)=P(A∣B)P(B),\mathbb{P}(B\mid A)\mathbb{P}(A)=\mathbb{P}(A\cap B)=\mathbb{P}(A\mid B)\mathbb{P}(B),

so

P(A∣B)=P(B∣A)P(B) P(A).\mathbb{P}(A\mid B)=\frac{\mathbb{P}(B\mid A)}{\mathbb{P}(B)}\,\mathbb{P}(A).

Annotations:

Random variables and distributions

A real-valued random variable is a measurable function x:Ω→Rx:\Omega\to\mathbb{R} defined on a probability space (Ω,F,P)(\Omega,\mathcal{F},\mathbb{P}).

A random vector is a measurable function x:Ω→Rnx:\Omega\to\mathbb{R}^n, i.e. x=(x1,…,xn)x=(x_1,\dots,x_n) with each xix_i a random variable.

The law/distribution of xx is the induced probability measure μx\mu_x on Rn\mathbb{R}^n:

μx(A):=P({ω∈Ω:x(ω)∈A})=P[x∈A]=P(x−1(A)).\mu_x(A):=\mathbb{P}(\{\omega\in\Omega: x(\omega)\in A\}) =\mathbb{P}[x\in A] =\mathbb{P}(x^{-1}(A)).

From a law to a question about data

The law tells us how to average any integrable quantity: E[f(x)]=∫f(z) μx(dz)\mathbb E[f(x)]=\int f(z)\,\mu_x(dz). In particular, for a real vector with finite second moment,

m=E[x],C=E[(x−m)(x−m)T],ℓTCℓ=E[(ℓT(x−m))2]≥0.m=\mathbb E[x],\qquad C=\mathbb E[(x-m)(x-m)^T],\qquad \ell^TC\ell=\mathbb E[(\ell^T(x-m))^2]\ge0.

Covariance is therefore a positive matrix for a reason: every directional test is a variance. Week 3 asks which distributions are completely described by this mean and covariance, and what observing some coordinates tells us about the others.