The Shape of a Random Vector

Covariance is a geometry

A face is a random vector

Four thousand numbers that move together

Neighboring pixels are not independent: a face is a shape, and the pixels move together. This week is about describing that shape, and about choosing the coordinates in which it is simplest.

The plan for the week

The geometry we borrow. Inner products, angles, right angles and projections, for ordinary vectors.

Covariance is that geometry. Two random variables have an angle between them; many have a covariance matrix, which is an ellipsoid.

Choosing the coordinates. Linear maps reshape the ellipsoid; the eigenvectors make it a sphere (whitening) or keep only what matters (the KLT). For a Gaussian vector, that is the whole story.

In the notes Vectors, Inner Products, and Orthogonality · Covariance and Correlation · Sums of Dependent Random Variables · Mean Vector and Covariance Matrix · Proper Complex Random Vectors · Linear Transforms of Random Vectors · Functions of Two Random Variables · Decorrelation, Whitening, and Coloring · Normal Random Vectors

The geometry we borrow

Inner product, length, distance

Euclidean inner product \[\ip{\mathbf x,\mathbf y}=\mathbf y\herm\mathbf x=\sum_{k=1}^Nx_k\,y_k\conj,\qquad \norm{\mathbf x}^2=\ip{\mathbf x,\mathbf x}=\sum_k\abs{x_k}^2 .\] It is linear in the first argument and conjugate-symmetric: \[\ip{a\mathbf x+b\mathbf z,\mathbf y}=a\ip{\mathbf x,\mathbf y}+b\ip{\mathbf z,\mathbf y},\qquad \ip{\mathbf y,\mathbf x}=\ip{\mathbf x,\mathbf y}\conj .\]

Complex from the start, because signals demand it. The conjugate is what makes \(\norm{\mathbf x}^2\ge0\), zero only at \(\mathbf 0\): for a signal, it is the energy. Distance is \(\norm{\mathbf x-\mathbf y}\), so “closest” always means the smallest norm of a difference.

Angle, and Cauchy–Schwarz

\[\abs{\ip{\mathbf x,\mathbf y}}\le\norm{\mathbf x}\,\norm{\mathbf y},\qquad \cos\theta=\frac{\abs{\ip{\mathbf x,\mathbf y}}}{\norm{\mathbf x}\norm{\mathbf y}}\in[0,1] .\]

\(\mathbf x\perp\mathbf y\) when \(\ip{\mathbf x,\mathbf y}=0\). That extreme case is the one this course lives on: orthogonality is the algebraic form of “carrying no information about each other”.

Pythagoras and the projection

\(\mathbf x\perp\mathbf y\ \Rightarrow\ \norm{\mathbf x+\mathbf y}^2=\norm{\mathbf x}^2+\norm{\mathbf y}^2\). The closest point of a subspace \(\mathcal S\) to \(\mathbf y\) is characterized by a right angle:

Projection theorem \[\norm{\mathbf y-\widehat{\mathbf y}}=\min_{\mathbf s\in\mathcal S}\norm{\mathbf y-\mathbf s} \iff(\mathbf y-\widehat{\mathbf y})\perp\mathcal S .\]

The projection onto the plane spanned by \(\mathbf x_1,\mathbf x_2\); the error stands perpendicular to the whole plane.

Coordinates in a basis

Gram matrix The Gram matrix of \(\mathbf x_1,\dots,\mathbf x_K\) collects all their pairwise inner products, \[[\mathbf R_{\mathbf{xx}}]_{ji}=\ip{\mathbf x_i,\mathbf x_j},\qquad i,j=1,\dots,K .\]

To write the best approximation of \(\mathbf y\) in this basis, \(\widehat{\mathbf y}=\sum_i\alpha_i\mathbf x_i\), demand the right angle \(\ip{\mathbf y-\widehat{\mathbf y},\mathbf x_j}=0\) against every \(\mathbf x_j\): \[\sum_{i=1}^K\alpha_i\ip{\mathbf x_i,\mathbf x_j}=\ip{\mathbf y,\mathbf x_j} \quad\Longleftrightarrow\quad \mathbf R_{\mathbf{xx}}\boldsymbol\alpha=\mathbf r_{\mathbf{xy}},\qquad [\mathbf r_{\mathbf{xy}}]_j=\ip{\mathbf y,\mathbf x_j}.\]

In an orthonormal basis \(\mathbf R_{\mathbf{xx}}=\mathbf I\) and each coefficient is one inner product, \(\alpha_j=\ip{\mathbf y,\mathbf x_j}\). Otherwise the coefficients couple.

Coordinates in a basis

Left: an orthonormal pair, where the coefficients are the perpendicular shadows. Middle: an oblique pair, where the true coefficients differ from the shadows. Right: a nearly parallel pair, where the same \(\mathbf y\) needs huge coefficients.

The shadows \(\mathbf r_{\mathbf{xy}}\) double-count whatever the basis vectors share; \(\mathbf R_{\mathbf{xx}}^{-1}\) removes the double counting. The more nearly parallel the basis, the worse conditioned \(\mathbf R_{\mathbf{xx}}\) and the larger the coefficients.

Functions are (generalized) vectors too

The first harmonics of the Fourier basis on an interval, partial sums of a square wave, and their Gram matrix: the identity.

With \(\ip{f,g}=\int f\,g\conj\), a function is a vector with a continuum of coordinates. The Fourier basis is orthonormal, so adding a harmonic never changes the earlier coefficients.

Same subspace, two bases

Monomials and Legendre polynomials span the same subspace; the best approximation is the same in both. Only the Gram matrix differs: dense for the monomials, identity for Legendre.

The projection depends only on the subspace; the basis only changes how hard it is to compute. Keep that distinction: this week is about choosing good bases.

Two variables: covariance

A population as three vectors

Height, weight and income of 240 people, each read as a centered list with one coordinate per person. Right: the cosines between the three lists.

A zero-mean random variable is such a list, with one coordinate per outcome, weighted by its probability. Weight follows height; income does not. That is an angle.

Only the angles enter

Weight \(\mathbf y\) from height \(\mathbf x_1\) and income \(\mathbf x_2\): three vectors of 240 coordinates each, redrawn from their pairwise angles alone. The Gram matrix is the whole input of the solve.

\(\mathbf R_{\mathbf{xx}}\) and \(\mathbf r_{\mathbf{xy}}\) are inner products, not coordinates: the projection depends on the pairwise angles, whatever the dimension of the vectors.

The error of the projection

Projection error The best approximation of \(\mathbf y\) from linearly independent \(\mathbf x_1,\dots,\mathbf x_K\) misses by \[\norm{\mathbf y-\widehat{\mathbf y}}^2=\norm{\mathbf y}^2-\mathbf r_{\mathbf{xy}}\herm\mathbf R_{\mathbf{xx}}^{-1}\mathbf r_{\mathbf{xy}} .\]

Proof. The error is perpendicular to \(\mathcal S\) and \(\widehat{\mathbf y}\in\mathcal S\), so Pythagoras gives \(\norm{\mathbf y}^2=\norm{\widehat{\mathbf y}}^2+\norm{\mathbf y-\widehat{\mathbf y}}^2\). For the first term, \[\norm{\widehat{\mathbf y}}^2=\ip{\widehat{\mathbf y},\mathbf y}-\underbrace{\ip{\widehat{\mathbf y},\mathbf y-\widehat{\mathbf y}}}_{0} =\sum_i\alpha_i\ip{\mathbf x_i,\mathbf y}=\mathbf r_{\mathbf{xy}}\herm\boldsymbol\alpha =\mathbf r_{\mathbf{xy}}\herm\mathbf R_{\mathbf{xx}}^{-1}\mathbf r_{\mathbf{xy}} .\qquad\blacksquare\]

Again only inner products. For the population, \(\norm{\mathbf y}=1\) and \(\mathbf r_{\mathbf{xy}}\herm\mathbf R_{\mathbf{xx}}^{-1}\mathbf r_{\mathbf{xy}}\approx0.80^2\): weight is missed by \(\norm{\mathbf y-\widehat{\mathbf y}}^2\approx0.36\).

Covariance is variance for a pair

Covariance and correlation coefficient \[C_{XY}=\E{(X-m_X)(Y-m_Y)\conj},\qquad \rho_{XY}=\frac{C_{XY}}{\sigma_X\sigma_Y},\qquad R_{XY}=\E{XY\conj}.\]

Uncorrelated and orthogonal \(X,Y\) are uncorrelated when \(C_{XY}=0\), and orthogonal when \(R_{XY}=0\).

Both are inner products, \(\ip{U,V}=\E{UV\conj}\): \(R_{XY}=\ip{X,Y}\) and \(C_{XY}=\ip{X-m_X,\,Y-m_Y}\). So uncorrelated means orthogonal once the means are removed, and \(\Var{X}=C_{XX}\) is a squared length.

Covariance is variance for a pair

The joint density, the weight \((x-m_X)(y-m_Y)\) with the sign of each quadrant, and their product, whose signed volume is \(C_{XY}\).

The correlation coefficient is a cosine

Cauchy–Schwarz on the centered variables, \(\ip{U,V}=\E{UV\conj}\): \(\ \abs{C_{XY}}\le\sigma_X\sigma_Y\ \Rightarrow\ \abs{\rho_{XY}}\le1\), with equality exactly when \(Y\) is affine in \(X\). What is \(\rho\) for each of these?

Uncorrelated is not independent

\(Y=X^2\) with a symmetric \(X\): \(Y\) is a function of \(X\), and yet \(C_{XY}=0\). Shift \(X\) and the same parabola gives \(\rho=0.97\).

Covariance sees only the straight-line part of the dependence. Zero covariance means “no linear relationship”, not “no relationship”.

Orthogonal is not uncorrelated

Uncorrelated (\(C_{XY}=0\)) and orthogonal (\(R_{XY}=0\)) differ by the means: \(C_{XY}=R_{XY}-m_Xm_Y\conj\).

One pair with \(\rho=-0.75\), placed so that \(\E{XY}=0\): quadrants about the origin cancel (left), quadrants about the mean do not (right).

independent \(\Rightarrow\) uncorrelated \(\overset{\text{zero mean}}{\iff}\) orthogonal, and no arrow reverses in general. This is why the course mostly works with zero-mean variables.

The dictionary

geometry random variables (zero mean)
inner product \(\ip{\mathbf x,\mathbf y}\) covariance \(\E{XY\conj}\)
squared length variance
\(\cos\theta\) correlation coefficient \(\rho_{XY}\)
orthogonal uncorrelated
Pythagoras variances of uncorrelated terms add
projection onto a subspace the best guess buildable from those variables

Nothing on the left knew about randomness, and nothing on the right will need a new proof.

Many variables: the covariance matrix

Moments become a vector and a matrix

Mean vector and covariance matrix \[\mathbf m_{\mathbf X}=\E{\mathbf X},\qquad \mathbf C_{\mathbf{XX}}=\E{(\mathbf X-\mathbf m_{\mathbf X})(\mathbf X-\mathbf m_{\mathbf X})\herm},\qquad \mathbf R_{\mathbf{XX}}=\E{\mathbf X\mathbf X\herm}.\]

For three components, variances on the diagonal and cross-covariances off it: \[\mathbf C_{\mathbf{XX}}=\begin{bmatrix}\Var{X_1}&C_{X_1X_2}&C_{X_1X_3}\\C_{X_2X_1}&\Var{X_2}&C_{X_2X_3}\\C_{X_3X_1}&C_{X_3X_2}&\Var{X_3}\end{bmatrix} .\]

Each pair appears twice: \(C_{X_jX_i}=C_{X_iX_j}\conj\), so the matrix is Hermitian, \(\mathbf C_{\mathbf{XX}}\herm=\mathbf C_{\mathbf{XX}}\).

Correlation-coefficient matrix \([\boldsymbol\rho_{\mathbf{XX}}]_{ij}=\rho_{X_iX_j}=\dfrac{C_{X_iX_j}}{\sigma_i\sigma_j}\), that is \(\boldsymbol\rho_{\mathbf{XX}}=\boldsymbol\Sigma^{-1}\mathbf C_{\mathbf{XX}}\boldsymbol\Sigma^{-1}\) with \(\boldsymbol\Sigma=\operatorname{diag}(\sigma_1,\dots,\sigma_N)\): ones on the diagonal, cosines off it.

The covariance matrix from data

\[\widehat{\mathbf m}_{\mathbf X}=\frac1M\sum_m\mathbf x^{(m)},\qquad \widehat{\mathbf C}_{\mathbf{XX}}=\frac{1}{M-1}\sum_m(\mathbf x^{(m)}-\widehat{\mathbf m}_{\mathbf X})(\mathbf x^{(m)}-\widehat{\mathbf m}_{\mathbf X})\herm:\] a sum of rank-one outer products, Hermitian by construction.

Figure 1: The 240 people from before, three measurements each: the covariance matrix (dominated by whichever variable has the largest units) and the correlation-coefficient matrix (unit-free).

The largest covariance tells you which variable has the biggest units (income, in kEUR), not which relationship is strongest. Normalizing to correlations makes the matrix readable: weight follows height, income follows neither.

The covariance matrix is a shape

Mahalanobis distance \(d_M(\mathbf x)=\sqrt{(\mathbf x-\mathbf m_{\mathbf X})\herm\,\mathbf C_{\mathbf{XX}}^{-1}\,(\mathbf x-\mathbf m_{\mathbf X})}\), for invertible \(\mathbf C_{\mathbf{XX}}\). Its level sets are the covariance ellipsoids; for \(N=1\) it is the \(z\)-score.

The ellipses are \(d_M=1,2\); the red arrows are the eigenvectors, scaled by \(\sqrt{\lambda_i}\). Uncorrelated components: the ellipse is axis-aligned. Correlation tilts it. Decorrelating the data means diagonalizing \(\mathbf C_{\mathbf{XX}}\), an eigenproblem and nothing more.

Complex random variables: the conjugate matters

\(Z=X+jY=Re^{j\Phi}\) is a pair of real variables on one outcome, and its size is measured with a conjugate: \(\E{ZZ\conj}=\E{\abs Z^2}\ge0\).

A unit-amplitude signal with uniform phase, \(Z=e^{j\Phi}\), \(\Phi\sim\Uniform(-\pi,\pi)\): \[\begin{aligned} \E{Z}&=\frac{1}{2\pi}\int_{-\pi}^{\pi}e^{j\varphi}\,d\varphi=0,\\ \E{Z^2}&=\frac{1}{2\pi}\int_{-\pi}^{\pi}e^{j2\varphi}\,d\varphi=0,\\ \E{ZZ\conj}&=\frac{1}{2\pi}\int_{-\pi}^{\pi}e^{j\varphi}e^{-j\varphi}\,d\varphi=1 . \end{aligned}\]

Without the conjugate, the second moment of a phase-rotating signal vanishes however large the signal is. With it, \(\mathbf C_{\mathbf{ZZ}}=\E{(\mathbf Z-\mathbf m)(\mathbf Z-\mathbf m)\herm}\) is Hermitian, exactly as in the real case.

Proper: one matrix is enough

\(\mathbf Z=\mathbf X+j\mathbf Y\) has \(2N\) real degrees of freedom; the missing half is the complementary covariance \(\widetilde{\mathbf C}_{\mathbf{ZZ}}=\E{(\mathbf Z-\mathbf m)(\mathbf Z-\mathbf m)\tran}\). A vector is proper when it vanishes.

Figure 2: Proper (left) and improper (right) complex variables with the same Hermitian variance.

Properness is rotational symmetry: no phase is privileged. A uniformly random carrier phase produces it, which makes it the standard model for communication and array signals.

Where proper signals come from

A narrowband tone across an array of microphones: one frequency, phases marching by a constant step, and an absolute phase the geometry does not fix.

The snapshot is \(\mathbf Z=Ae^{j\Theta}\mathbf v+\mathbf N\) with \(\Theta\) uniform.

The unknown absolute phase is what makes the snapshot proper.

Linear maps

A map deforms the plane

Change of variables For an invertible, differentiable map \(\mathbf Y=g(\mathbf X)\) of a random vector, with Jacobian \(\mathbf J_g=\bracket{\partial g_i/\partial x_j}\): \[f_{\mathbf Y}(\mathbf y)=\frac{f_{\mathbf X}(\mathbf x)}{\abs{\det\mathbf J_g(\mathbf x)}}\bigg|_{\mathbf x=g^{-1}(\mathbf y)}, \qquad\text{linear: }\ f_{\mathbf Y}(\mathbf y)=\frac{f_{\mathbf X}\paren{\mathbf A^{-1}(\mathbf y-\mathbf b)}}{\abs{\det\mathbf A}} .\]

A rotation times a stretch, \(\abs{\det\mathbf A}=1.23\): the law is carried along and thinned by \(1.23\).

Probability is conserved: where the map stretches area, the density thins by the same factor.

Three elementary maps

Scaling changes variances and leaves the correlation coefficient alone. A rotation keeps every length and eigenvalue and changes only which direction is which. A shear creates correlation.

A sum is a shear

The sum as the shear \((x,y)\mapsto(x+y,\,y)\), on the grid and on a law: lines of constant sum become vertical, and integrating out \(w\) leaves the density of the sum.

Shear, then marginalize: \(\abs{\det\mathbf J}=1\), so no density is rescaled, only moved. For independent terms this is the convolution of densities, the smoothing step of the first week drawn as a map.

The most used fact at this level

Moments under a linear map For \(\mathbf Y=\mathbf A\mathbf X+\mathbf b\): \[\mathbf m_{\mathbf Y}=\mathbf A\mathbf m_{\mathbf X}+\mathbf b,\qquad \mathbf C_{\mathbf{YY}}=\mathbf A\,\mathbf C_{\mathbf{XX}}\,\mathbf A\herm ,\] \[\mathbf R_{\mathbf{YY}}=\mathbf A\mathbf R_{\mathbf{XX}}\mathbf A\herm+\mathbf A\mathbf m_{\mathbf X}\mathbf b\herm +\mathbf b\,\mathbf m_{\mathbf X}\herm\mathbf A\herm+\mathbf b\mathbf b\herm =\mathbf C_{\mathbf{YY}}+\mathbf m_{\mathbf Y}\mathbf m_{\mathbf Y}\herm .\]

One line of proof: linearity of expectation. The offset moves the mean and cannot touch the covariance; it does enter \(\mathbf R_{\mathbf{YY}}\), and for \(\mathbf b=\mathbf 0\) the correlation transforms like the covariance, \(\mathbf R_{\mathbf{YY}}=\mathbf A\mathbf R_{\mathbf{XX}}\mathbf A\herm\). For one row, \(\Var{\mathbf a\herm\mathbf X}=\mathbf a\herm\mathbf C_{\mathbf{XX}}\mathbf a\).

Every filter, beamformer and transform is an \(\mathbf A\), and this is what it does to the second-order description, whatever the distribution.

The variance in every direction

A linear combination \(\mathbf a\herm\mathbf X\) is a directional marginal, the joint law squashed onto direction \(\mathbf a\). A variance cannot be negative, so \(\Var{\mathbf a\herm\mathbf X}=\mathbf a\herm\mathbf C_{\mathbf{XX}}\mathbf a\ge0\) for every \(\mathbf a\): \(\mathbf C_{\mathbf{XX}}\) is positive semidefinite.

As \(\mathbf a\) turns, the variance swings between the eigenvalues, reached along the eigenvectors; every other direction is trapped between them.

The covariance of a sum

Summing all components is a map with one row, \(S=\sum_kX_k=\mathbf 1\herm\mathbf X\) with \(\mathbf 1=[1,\dots,1]\tran\): \[\Var{S}=\mathbf 1\herm\mathbf C_{\mathbf{XX}}\mathbf 1=\sum_k\sum_lC_{X_kX_l} .\]

Two random vectors: stack them, \(\mathbf X+\mathbf Y=\begin{bmatrix}\mathbf I&\mathbf I\end{bmatrix}\begin{bmatrix}\mathbf X\\\mathbf Y\end{bmatrix}\). The stacked covariance holds the cross-covariances \(\mathbf C_{\mathbf{XY}}=\E{(\mathbf X-\mathbf m_{\mathbf X})(\mathbf Y-\mathbf m_{\mathbf Y})\herm}\): \[\mathbf C_{\mathbf X+\mathbf Y}=\begin{bmatrix}\mathbf I&\mathbf I\end{bmatrix} \begin{bmatrix}\mathbf C_{\mathbf{XX}}&\mathbf C_{\mathbf{XY}}\\\mathbf C_{\mathbf{YX}}&\mathbf C_{\mathbf{YY}}\end{bmatrix} \begin{bmatrix}\mathbf I\\\mathbf I\end{bmatrix} =\mathbf C_{\mathbf{XX}}+\mathbf C_{\mathbf{XY}}+\mathbf C_{\mathbf{YX}}+\mathbf C_{\mathbf{YY}} .\]

Uncorrelated terms, \(\mathbf C_{\mathbf{XY}}=\mathbf 0\): the covariances simply add.

Sums of dependent terms

Puzzle: add a second noisy term to the first. Does the variance of the sum always grow?

With \(\mathbf 1=[1,1]\tran\), the quadratic form of the slide before gives \[\Var{X+Y}=\Var{X}+\Var{Y}+2\,C_{XY} .\]

Negatively dependent Gaussians nearly cancel, so the sum is narrow.

No: a negative covariance subtracts, and the sum can be smaller than either term. Variances add only for uncorrelated terms, and that is Pythagoras.

Averaging of dependent measurements

Average \(N\) observations of variance \(\sigma^2\), with a common correlation \(\rho\) between any two: \(\overline X_N=\frac1N\sum_kX_k\). How effective is the averaging?

The \(N\) diagonal and \(N(N-1)\) off-diagonal terms of the double sum give \[\Var{\overline X_N}=\frac{1}{N^2}\sum_{k,l}C_{X_kX_l}=\frac{\sigma^2}{N}\bracket{1+(N-1)\rho} =\frac{\sigma^2}{N_{\text{eff}}},\qquad N_{\text{eff}}=\frac{N}{1+(N-1)\rho}\ \xrightarrow{N\to\infty}\ \frac1\rho .\]

Noisy measurements

The array snapshot \(\mathbf Z=Ae^{j\Theta}\mathbf v+\mathbf N\): a source of fixed amplitude \(A\) and uniform phase \(\Theta\), plus white noise \(\mathbf C_{\mathbf{NN}}=\sigma_N^2\mathbf I\) uncorrelated with the source.

The source term has zero mean and covariance \(\E{\abs A^2e^{j\Theta}e^{-j\Theta}}\mathbf v\mathbf v\herm=\abs A^2\mathbf v\mathbf v\herm\); the two terms are uncorrelated, so the covariances add: \[\mathbf C_{\mathbf{ZZ}}=\abs A^2\,\mathbf v\mathbf v\herm+\sigma_N^2\mathbf I .\]

One strong direction lifted above an isotropic noise floor. The rank-one term is where the direction of the source is written.

Choosing the coordinates

Choosing \(\mathbf A\) is the whole game

In \(\mathbf C_{\mathbf{YY}}=\mathbf A\mathbf C_{\mathbf{XX}}\mathbf A\herm\), choose \(\mathbf A\) to make

  • \(\mathbf C_{\mathbf{YY}}\) diagonal: the outputs are uncorrelated (decorrelation);
  • \(\mathbf C_{\mathbf{YY}}=\mathbf I\): uncorrelated and of unit scale (whitening);
  • \(\mathbf C_{\mathbf{YY}}\) equal to a target: a signal with prescribed statistics (coloring).

The mixture law rotated through a full turn. Four times per turn the off-diagonal of \(\mathbf C_{\mathbf{YY}}\) passes through zero: there the rotation lines the axes up with the ellipse, and the outputs are uncorrelated.

The natural axes: eigenvectors

\[\mathbf C_{\mathbf{XX}}=\mathbf U\boldsymbol\Lambda\mathbf U\herm,\qquad \mathbf U\herm\mathbf U=\mathbf I,\quad \lambda_i\ge0 .\]

Hermitian gives the orthonormal \(\mathbf U\); positive semidefinite gives \(\lambda_i\ge0\). Transform by \(\mathbf U\herm\): \(\mathbf C_{\mathbf{WW}}=\mathbf U\herm\mathbf C_{\mathbf{XX}}\mathbf U=\boldsymbol\Lambda\), diagonal.

Figure 3: The three-Gaussian mixture with its principal axes, and the same cloud after the rotation Uᴴ.

Whitening: ellipsoid into sphere

\(\mathbf A\) whitens \(\mathbf X\) if \(\mathbf A\mathbf C_{\mathbf{XX}}\mathbf A\herm=\mathbf I\). The eigenvectors solve it on sight: \(\mathbf A_{\text{PCA}}=\boldsymbol\Lambda^{-1/2}\mathbf U\herm\), rotate, then divide each axis by its own standard deviation.

Figure 4: The two steps of whitening: the rotation keeps the shape, the rescaling makes it a sphere.

In whitened coordinates the Mahalanobis distance is ordinary Euclidean distance. Whitening is a change of metric, and every \(\mathbf C^{-1}\) that appears later in the course is this change of metric at work.

Whitening is never unique

All whiteners \(\mathbf A\) whitens \(\mathbf X\) if and only if \(\mathbf A=\mathbf Q\,\boldsymbol\Lambda^{-1/2}\mathbf U\herm\) for some unitary \(\mathbf Q\) (for invertible \(\mathbf C_{\mathbf{XX}}=\mathbf U\boldsymbol\Lambda\mathbf U\herm\)).

Proof. \((\Leftarrow)\) Insert \(\mathbf A=\mathbf Q\boldsymbol\Lambda^{-1/2}\mathbf U\herm\): \[\mathbf A\mathbf C_{\mathbf{XX}}\mathbf A\herm =\mathbf Q\boldsymbol\Lambda^{-1/2}\underbrace{\mathbf U\herm\mathbf U}_{\mathbf I}\boldsymbol\Lambda\underbrace{\mathbf U\herm\mathbf U}_{\mathbf I}\boldsymbol\Lambda^{-1/2}\mathbf Q\herm =\mathbf Q\mathbf Q\herm=\mathbf I .\]

\((\Rightarrow)\) Let \(\mathbf A\) whiten and set \(\mathbf Q=\mathbf A\mathbf U\boldsymbol\Lambda^{1/2}\). It is unitary, \[\mathbf Q\mathbf Q\herm=\mathbf A\,\mathbf U\boldsymbol\Lambda\mathbf U\herm\mathbf A\herm=\mathbf A\mathbf C_{\mathbf{XX}}\mathbf A\herm=\mathbf I ,\] and solving for \(\mathbf A\) gives \(\mathbf A=\mathbf Q\boldsymbol\Lambda^{-1/2}\mathbf U\herm\). \(\blacksquare\)

So choosing \(\mathbf Q\) is choosing what else the transform should do.

Three whiteners, three extra properties

whitener \(\mathbf A\) what else it buys
PCA \(\boldsymbol\Lambda^{-1/2}\mathbf U\herm\) coordinates ordered by variance
ZCA \(\mathbf U\boldsymbol\Lambda^{-1/2}\mathbf U\herm=\mathbf C^{-1/2}\) the output changes least from the input
Cholesky \(\mathbf D^{-1/2}\mathbf L^{-1}\), from \(\mathbf C=\mathbf L\mathbf D\mathbf L\herm\) causal: output \(i\) uses only inputs \(1,\dots,i\)

Coloring: the same factor, backwards

To generate a vector with covariance \(\mathbf C\), factor it and push white noise through:

Coloring \[\mathbf C=\mathbf L\mathbf D\mathbf L\herm,\qquad \mathbf X=\mathbf L\mathbf D^{1/2}\mathbf W,\quad \mathbf C_{\mathbf{WW}}=\mathbf I \quad\Longrightarrow\quad\mathbf C_{\mathbf{XX}}=\mathbf L\mathbf D\mathbf L\herm=\mathbf C .\]

Figure 5: The mixture whitened by D⁻¹ᐟ²L⁻¹ (left) and colored back by LD¹ᐟ² (right), with the ellipses d_M = 2.

Any whitening factor run backwards will do: the symmetric root \(\mathbf C^{1/2}\) or a Cholesky factor. If \(\mathbf W\) is Gaussian, so is \(\mathbf X\).

Keeping only what matters

Every face is \(N=4096\) numbers, and the pixels move together. Can we store far fewer numbers per face?

Subtract the mean face, so \(\E{\mathbf X}=\mathbf 0\). Encode each face by a latent \(\mathbf W\in\mathbb C^K\), \(K\ll N\), and decode linearly, \(\widehat{\mathbf X}_K=\mathbf A\mathbf W\) with \(\mathbf A\in\mathbb C^{N\times K}\): \[\min_{\mathbf A,\ \mathbf W}\ \E{\norm{\mathbf X-\mathbf A\mathbf W}^2} .\]

Rotate, truncate, rotate back

The Karhunen–Loève transform (KLT)

The three steps of the slide before, in symbols: \[\widehat{\mathbf X}_K=\underbrace{\mathbf U}_{\text{rotate back}}\ \underbrace{\mathbf T}_{\text{truncate}}\ \underbrace{\mathbf U\herm}_{\text{rotate}}\mathbf X, \qquad \mathbf T=\operatorname{diag}(\underbrace{1,\dots,1}_{K},0,\dots,0) .\]

\(\mathbf T\) sets all but the first \(K\) coordinates to zero, so only the first \(K\) columns of \(\mathbf U\) survive, \(\mathbf U\mathbf T\mathbf U\herm=\mathbf U_K\mathbf U_K\herm\) with \(\mathbf U_K=[\mathbf u_1,\dots,\mathbf u_K]\): \[\widehat{\mathbf X}_K=\mathbf U_K\underbrace{\mathbf U_K\herm\mathbf X}_{\mathbf W\in\mathbb C^K} .\]

Karhunen–Loève The encoder \(\mathbf W=\mathbf U_K\herm\mathbf X\) and the decoder \(\mathbf A=\mathbf U_K\) minimize the mean-square error. The latent is uncorrelated and keeps the \(K\) largest variances: padded with zeros, \(\mathbf W=\mathbf T\mathbf U\herm\mathbf X\) has \(\mathbf C_{\mathbf{WW}}=\mathbf T\boldsymbol\Lambda\mathbf T\herm=\mathbf T\boldsymbol\Lambda\). The discarded coordinates \(\mathbf u_i\herm\mathbf X\), \(i>K\), carry the error, with variance \(\lambda_i\) each: \(\E{\norm{\mathbf X-\widehat{\mathbf X}_K}^2}=\sum_{i=K+1}^N\lambda_i\).

Eigenfaces

Coarse illumination first, fine detail last. A few dozen numbers describe a face of 4096 pixels, because the pixels move together. Nothing about faces was built into the method: the basis was read off the covariance alone.

New faces from the latent space

The coordinates \(\mathbf W=\mathbf U_K\herm(\mathbf X-\mathbf m)\) are uncorrelated with variances \(\lambda_i\). Model them as independent Gaussians, draw a new \(\mathbf w\), and map back: \(\mathbf x_{\text{new}}=\mathbf m+\mathbf U_K\mathbf w\).

Two moments make a generative model: the faces are new and plausible, but blurred and alike, because a Gaussian on \(K=50\) coordinates knows nothing beyond the covariance.

The Gaussian vector

Two moments are the whole law

Jointly Gaussian vector \[f_{\mathbf X}(\mathbf x)=\frac{1}{\sqrt{(2\pi)^N\det\mathbf C_{\mathbf{XX}}}} \exp\paren{-\tfrac12\,d_M^2(\mathbf x)} .\]

Figure 6: Left: the quadratic form d_M², a bowl. Right: exp(−d_M²/2), a bell with the same contours.

The 68–95–99.7 rule does not survive dimension

Left: level sets of a 2-D Gaussian and the probability each encloses. Right: \(d_M^2\sim\chi^2_N\), so the same radius encloses less and less as \(N\) grows.

In one dimension \(d_M\le1\) holds 68% of the mass, in two 39%, in three 20%. In high dimension almost all the mass lies far from the mean, measured in standard deviations: estimation gets harder with dimension.

Two properties that carry the course

The Gaussian vector

  • Closed under linear maps. \(\mathbf A\mathbf X+\mathbf b\) is Gaussian, with mean \(\mathbf A\mathbf m+\mathbf b\) and covariance \(\mathbf A\mathbf C_{\mathbf{XX}}\mathbf A\herm\): filtering and beamforming never leave the family.
  • Uncorrelated means independent. A diagonal \(\mathbf C_{\mathbf{XX}}\) turns \(d_M^2\) into a sum of squares, and the density factors.

Proof of the second. With \(\mathbf C_{\mathbf{XX}}=\operatorname{diag}(\sigma_1^2,\dots,\sigma_N^2)\), \[d_M^2(\mathbf x)=(\mathbf x-\mathbf m)\herm\mathbf C_{\mathbf{XX}}^{-1}(\mathbf x-\mathbf m)=\sum_{i=1}^N\frac{(x_i-m_i)^2}{\sigma_i^2},\qquad \det\mathbf C_{\mathbf{XX}}=\prod_{i=1}^N\sigma_i^2,\] \[f_{\mathbf X}(\mathbf x)=\prod_{i=1}^N\frac{1}{\sqrt{2\pi\sigma_i^2}}\exp\paren{-\frac{(x_i-m_i)^2}{2\sigma_i^2}}=\prod_{i=1}^Nf_{X_i}(x_i) .\ \blacksquare\]

“Jointly” matters

Same marginals, same covariance; the dashed curve is the Gaussian of the same variance. Folding the mass of two quadrants into the other two keeps both coordinates standard normal, yet the diagonal projection has no mass near zero.

The proper complex Gaussian

\[f_{\mathbf Z}(\mathbf z)=\frac{1}{\pi^N\det\mathbf C_{\mathbf{ZZ}}} \exp\paren{-(\mathbf z-\mathbf m)\herm\mathbf C_{\mathbf{ZZ}}^{-1}(\mathbf z-\mathbf m)}\]

Figure 7: A scalar proper complex Gaussian: a circular blob; radius and phase independent; the radius is Rayleigh.

The flat phase panel is properness seen directly. This is the standard model for receiver noise.

CLT in higher dimensions

For iid random vectors with finite covariance, the normalized sum is Gaussian: \(\frac{1}{\sqrt n}\sum_i(\mathbf X_i-\mathbf m)\to\Gauss(\mathbf 0,\mathbf C)\). Proof: apply the scalar central limit theorem to every projection \(\mathbf a\herm\mathbf X\).

Figure 8: Normalized sums of n iid uniform 2-vectors, sheared so the components are correlated.

The square becomes an ellipse whose contours are set by \(\mathbf C\) alone: the first week’s answer, now for vectors.

Recap

This week

  1. Covariance is an inner product, and correlation a cosine. It sees only linear dependence, and correlated measurements are worth fewer than their number.
  1. The covariance matrix is an ellipsoid: \(\mathbf a\herm\mathbf C\mathbf a\) is the variance in direction \(\mathbf a\), and a linear map sends \(\mathbf C\) to \(\mathbf A\mathbf C\mathbf A\herm\).
  1. The eigenvectors are the natural coordinates. Rotating to them decorrelates, rescaling whitens (a change of metric), and keeping the leading ones is the best compression there is. For a Gaussian vector these two moments are the whole story.