Covariance is a geometry
\[ % Number sets \newcommand{\Nat}{\mathbb{N}} \newcommand{\Integer}{\mathbb{Z}} \newcommand{\Real}{\mathbb{R}} \newcommand{\Complex}{\mathbb{C}} % Operators \newcommand{\SNR}{\operatorname{SNR}} \newcommand{\tr}{\operatorname{tr}} \newcommand{\re}{\operatorname{Re}} \newcommand{\im}{\operatorname{Im}} \newcommand{\sign}{\operatorname{sign}} \newcommand{\rect}{\operatorname{rect}} \newcommand{\sinc}{\operatorname{si}} \newcommand{\erf}{\operatorname{erf}} \newcommand{\erfc}{\operatorname{erfc}} \newcommand{\kurt}{\operatorname{kurt}} \newcommand{\diag}{\operatorname{diag}} \newcommand{\MSE}{\operatorname{MSE}} \newcommand{\argmin}{\operatorname*{argmin}} \newcommand{\argmax}{\operatorname*{argmax}} \newcommand{\bias}{\operatorname{bias}} \newcommand{\Bin}{\operatorname{Bin}} % Delimiters \newcommand{\paren}[1]{\left(#1\right)} \newcommand{\bracket}[1]{\left[#1\right]} \newcommand{\set}[1]{\left\{#1\right\}} \newcommand{\abs}[1]{\left\lvert #1 \right\rvert} \newcommand{\norm}[1]{\left\lVert #1 \right\rVert} \newcommand{\ip}[1]{\left\langle #1 \right\rangle} % Notation \newcommand{\dd}{\,\mathrm{d}} \newcommand{\tran}{^{\top}} \newcommand{\conv}{\ast} \newcommand{\conj}{^{*}} \newcommand{\herm}{^{\mathsf{H}}} \newcommand{\opt}{^{\star}} % Expectation and variance % \newcommand{\E}[1]{\mathbb{E}\!\left[#1\right]} \newcommand{\E}[2][]{\mathbb{E}_{#1}\!\left[#2\right]} \newcommand{\Var}[1]{\mathbb{V}\!\left[#1\right]} % Distributions \newcommand{\Gauss}{\mathcal{N}} \newcommand{\Uniform}{\mathcal{U}} \newcommand{\FT}{\mathcal{F}} % Probability \newcommand{\Prob}[1]{\mathbb{P}\!\left(#1\right)} % Misc \newcommand{\bsy}[1]{\boldsymbol{#1}} \newcommand{\calR}{\mathcal{R}} \newcommand{\calC}{\mathcal{C}} \]

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 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 · Decorrelation, Whitening, and Coloring · Normal Random Vectors
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 .\]
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.
\[\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”.
\(\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 .\]

Nothing here used that a vector is a list of numbers, only that there is an inner product. Any space carrying one inherits all of it.

In an orthonormal basis each coefficient is one inner product. In an oblique basis the coefficients come from a linear system whose matrix, the Gram matrix, holds all the pairwise inner products of the basis.

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.

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.

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.

\(\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.
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}.\]

Cauchy–Schwarz applied to the centered variables, with \(\ip{U,V}=\E{UV\conj}\): \[\abs{C_{XY}}\le\sigma_X\sigma_Y\quad\Longrightarrow\quad\abs{\rho_{XY}}\le1,\] with equality exactly when \(Y\) is an affine function of \(X\).


Covariance sees only the straight-line part of the dependence. Zero covariance means “no linear relationship”, not “no relationship”.
\(X,Y\) are uncorrelated when \(C_{XY}=0\), orthogonal when \(R_{XY}=\E{XY\conj}=0\). They differ by the means: \(C_{XY}=R_{XY}-m_Xm_Y\conj\).

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.
| 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.
The variance of a sum keeps its cross terms: \[\Var{\overline X_N}=\frac{1}{N^2}\sum_{k,l}C_{X_kX_l} =\frac{\sigma^2}{N_{\text{eff}}},\qquad N_{\text{eff}}=\frac{N}{1+(N-1)\rho}\] for a common correlation \(\rho\) between any two readings.

Correlated readings repeat each other. With \(\rho=0.5\), a million readings are worth two. The \(1/\sqrt N\) of independent averaging was a property of independence, not of averaging.
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}.\]
The diagonal holds the variances, the off-diagonal entries the pairwise covariances. Two properties: Hermitian, \(\mathbf C_{\mathbf{XX}}\herm=\mathbf C_{\mathbf{XX}}\), and positive semidefinite, \[\mathbf a\herm\mathbf C_{\mathbf{XX}}\mathbf a=\Var{\mathbf a\herm\mathbf X}\ge0\qquad\text{for every }\mathbf a .\]
Not a technicality: positive semidefiniteness licenses every square root, inverse and eigen- decomposition used from here to the end of the course.
Uncorrelated components: the ellipse is axis-aligned. Correlation tilts it. Decorrelating the data means diagonalizing \(\mathbf C_{\mathbf{XX}}\), an eigenproblem and nothing more.

The extremes are the eigenvalues, reached along the eigenvectors; every other direction is trapped between them.
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})}.\] Its level sets are the covariance ellipsoids. For \(N=1\) it is the \(z\)-score.

An outlier cannot be judged coordinate by coordinate: this point is unusual because it disobeys the correlation the rest of the data obey.
\[\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, positive semidefinite by construction.
The largest covariance tells you which variable has the biggest units, not which relationship is strongest. Normalizing to correlations makes the matrix readable.
\(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\).
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 and positive semidefinite, exactly as in the real case.
\(\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.
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.

The snapshot is \(\mathbf Z=Ae^{j\Theta}\mathbf v+\mathbf N\) with \(\Theta\) uniform. Its covariance \(\abs A^2\mathbf v\mathbf v\herm+\sigma_N^2\mathbf I\) is one strong direction lifted above an isotropic noise floor.
The unknown absolute phase is what makes the snapshot proper, and the rank-one term is where the direction of the source is written.
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 .\]
One line of proof: linearity of expectation. The offset moves the mean and cannot touch the covariance. For one row, \(\Var{\mathbf a\herm\mathbf X}=\mathbf a\herm\mathbf C_{\mathbf{XX}}\mathbf a\) again.
Every filter, beamformer and transform is an \(\mathbf A\), and this is what it does to the second-order description, whatever the distribution.

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.
In \(\mathbf C_{\mathbf{YY}}=\mathbf A\mathbf C_{\mathbf{XX}}\mathbf A\herm\), choose \(\mathbf A\) to make

When the whole density is wanted, a bijection \(\mathbf Y=\mathbf g(\mathbf X)\) rescales it by the local volume change:
Change of variables \[f_{\mathbf Y}(\mathbf y)=\frac{f_{\mathbf X}(\mathbf x)}{\abs{\det\mathbf J(\mathbf x)}}\Big|_{\mathbf x=\mathbf g^{-1}(\mathbf y)} .\]
For a linear map the Jacobian is the constant \(\mathbf A\): \(f_{\mathbf Y}(\mathbf y)=f_{\mathbf X}\paren{\mathbf A^{-1}(\mathbf y-\mathbf b)}/\abs{\det\mathbf A}\).
\[\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.
\(\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.
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.
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\).
A sphere looks the same from every angle, so any rotation after whitening whitens just as well. And every whitener maps \(d_M\) onto Euclidean distance: \(\mathbf Q\) decides which direction becomes which coordinate, never how far apart two points are.
So choosing \(\mathbf Q\) is choosing what else the transform should do.

| 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}\) | causal: output \(i\) uses only inputs \(1,\dots,i\) |
→ Demo: the covariance ellipse, Mahalanobis distance, and three whiteners
To generate a vector with covariance \(\mathbf C\), factor it and push white noise through:
Coloring \[\mathbf C=\mathbf L\mathbf L\herm,\qquad \mathbf X=\mathbf L\mathbf W,\quad \mathbf C_{\mathbf{WW}}=\mathbf I \quad\Longrightarrow\quad\mathbf C_{\mathbf{XX}}=\mathbf L\mathbf L\herm=\mathbf C .\]
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\).
Whitening and coloring are one matrix used in two directions: \(\mathbf L^{-1}\) pre-whitens an observation, \(\mathbf L\) generates correlated test signals.
The circle is stretched and sheared into the target ellipse; the sample covariance matches the target. This is how correlated test noise is made.
A different question: among all orthonormal bases, which one lets you throw the most away?
Karhunen–Loève Keeping the \(K\) leading eigen-coordinates minimizes the mean-square truncation error over all orthonormal bases, and the minimum is the tail of the spectrum, \(\E{\norm{\mathbf X-\widehat{\mathbf X}_K}^2}=\sum_{i=K+1}^N\lambda_i\).
Why. In any orthonormal basis the error is the discarded energy; the total \(\tr\mathbf C=\sum\lambda_i\) does not depend on the basis; and the largest energy any \(K\)-dimensional subspace can capture is \(\sum_{i\le K}\lambda_i\), on the leading eigenvectors.
The optimal subspace is unique; the basis inside it is not. Energy compaction fixes the subspace; decorrelation is what singles out the eigenbasis within it.

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.
No correlation, no compression Faces occupy a tiny, strongly correlated corner of pixel space. Where the data have no such structure, \(\mathbf C_{\mathbf{XX}}\) is near-isotropic, the spectrum is flat, and the theorem promises nothing.
The optimal basis depends on \(\mathbf C_{\mathbf{XX}}\) and must be shipped with every file. That is why practical codecs use a fixed basis and accept a little suboptimality.
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)} .\]
The level sets of the density are exactly the covariance ellipsoids. For a Gaussian vector the mean and the covariance are not a summary; they are everything.

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.
The Gaussian vector
The second line is why, under a Gaussian model, the best linear estimator turns out to be the best estimator of any kind.

\(\mathbf X\) is jointly Gaussian if and only if every projection \(\mathbf a\herm\mathbf X\) is Gaussian. Two marginals are just two projections out of infinitely many; the diagonal one gives \((X,SX)\) away, since \(X+SX\) is exactly zero half the time.
\[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)}\]
The flat phase panel is properness seen directly. This is the standard model for receiver noise.
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\).
The square becomes an ellipse whose contours are set by \(\mathbf C\) alone: the first week’s answer, now for vectors.
This week