Module contents
Lesson 24 of 24Research 110 min

Frontier: random matrices and matrix concentration

When dimension grows with the amount of data, scalar probability is insufficient: random-matrix spectra matter. Study matrix Bernstein and covariance estimation error, extreme singular values, the semicircle and Marchenko–Pastur laws, and the BBP transition in spiked models. These tools underpin current research on double descent, high-dimensional PCA and trained-network weight spectra.

After this lesson you can

  • Apply matrix Bernstein to bound ‖Σ̂ - Σ‖ and determine the required sample size.
  • Bound extreme singular values of Gaussian matrices using ε-nets.
  • Derive the semicircle law by the method of moments and recognize the Marchenko–Pastur law.
  • Explain the BBP transition and its consequences for PCA when d/n is not negligible.
  • Critically read papers using random matrices to analyze neural networks.

Before you start

Motivation: pure noise that looks like structure

Take n=400n = 400 observations of d=200d = 200 independent variables, all with mean 0 and variance 1. The true covariance matrix is Σ=I\mat{\Sigma} = \mat{I}: all 200 eigenvalues are 1 and no direction is special. Now compute sample covariance Σ^=1n∑ixixi⊤\hat{\mat{\Sigma}} = \frac1n\sum_i \vb{x}_i\vb{x}_i\T and run PCA. The largest eigenvalue is near 2.92.9 and the smallest near 0.090.09; condition number, which should be 1, is around 30 (and tends to 34 as nn and dd grow in that ratio); the first 20 components, 10% of the total, ‘explain’ about 24% of variance. An unwary analyst might see low-rank structure with smooth spectral decay. It is noise.

InteractiveNoise looks like structure
Eigenvalues of sample covariance Σ^\hat{\mat{\Sigma}} with Σ=I\mat{\Sigma} = \mat{I}
truth: all equal 1calculating…
  • eigenvalues of Σ^\hat{\mat{\Sigma}}
  • true (all 1)
  • Marchenko-Pastur
  • edges (1±γ)2(1 \pm \sqrt\gamma)^2
Scree plot: ordered eigenvalues
  • eigenvalues of Σ^\hat{\mat{\Sigma}}, largest to smallest
  • flat truth
  • Marchenko–Pastur quantiles
0.50
Data and dimensionn = 400, d = 200
Largest eigenvalue; edge (1+γ)2(1 + \sqrt\gamma)^2…
Smallest nonzero; edge (1−γ)2(1 - \sqrt\gamma)^2…
Condition number (true value: 1)…
Variance explained by top 10% (… components)…
n=400n = 400 Gaussian observations with Σ=I\mat{\Sigma} = \mat{I} in dimension d=γnd = \gamma n. Left: histogram of eigenvalues of Σ^\hat{\mat{\Sigma}}; orange line marks all true eigenvalues, gray curve is Marchenko-Pastur density predicting the histogram without free parameters. Right: the PCA scree plot, ordered eigenvalues against flat truth. At γ=0.5\gamma = 0.5 the spectrum runs from 0.090.09 to 2.92.9. Move γ\gamma toward 0 (classical regime, n≫dn \gg d) and 1, where the smallest eigenvalue reaches zero; then above 1, where Σ^\hat{\mat{\Sigma}} loses full rank.

This does not contradict the law of large numbers. Each entry of Σ^\hat{\mat{\Sigma}} converges to its counterpart in Σ\mat{\Sigma} with error of order 1/n1/\sqrt n. Scale is the problem: there are d2d^2 entries, and the error’s operator norm, which moves eigenvalues, accumulates fluctuations coherently. With γ=d/n\gamma = d/n fixed, error ∥Σ^−I∥\norm{\hat{\mat{\Sigma}} - \mat{I}} does not tend to 0 but 2γ+γ2\sqrt\gamma + \gamma, which for γ=0.5\gamma = 0.5 is 1.911.91. Earlier scalar probability answered ‘how far does an average depart from its mean?’; this lesson asks ‘how far does a random matrix spectrum depart from the spectrum of its mean?’ at three levels:

  1. Nonasymptotic bounds (matrix concentration): matrix Bernstein and extreme singular values provide bounds for each nn and dd, determining covariance sample requirements.
  2. Limit laws (random matrix theory): when n,d→∞n, d \to \infty with d/n→γd/n \to \gamma, the whole eigenvalue distribution converges to a deterministic law: Wigner’s semicircle for symmetric matrices and Marchenko-Pastur for covariances.
  3. Phase transitions: a low-rank signal buried in noise is spectrally visible only above an exact threshold. Below it, PCA is blind even with infinite proportional data.

This language appears throughout current research: regression error double descent, high-dimensional PCA, deep-network initialization and spectra of trained-network weights. The end examines real GPT-2 data.

Matrix concentration: Bernstein’s inequality

Start nonasymptotically. Let Z=∑kXk\mat{Z} = \sum_k \mat{X}_k be a sum of independent centered symmetric random matrices d×dd\times d. Bound ∥Z∥\norm{\mat{Z}}, its largest singular value. A first attempt uses ∥Z∥=max⁡∥u∥=1∣u⊤Zu∣\norm{\mat{Z}} = \max_{\norm{\vb{u}} = 1}\abs{\vb{u}\T\mat{Z}\vb{u}}: for each fixed u\vb{u}, u⊤Zu\vb{u}\T\mat{Z}\vb{u} is a scalar sum to which Bernstein applies, and an ε-net of the sphere controls the maximum. This works but the net has eO(d)e^{\bigO(d)} points and union costs factor d\sqrt d. A better tool works directly with matrices and pays only log⁡d\log d.

This is the matrix Bernstein inequality. Compare scalar Bernstein: the same expression with σ2\sigma^2 replaced by the norm of the sum of matrix second moments, and a leading dd factor. This dimensional price cannot generally be removed: if Xk\mat{X}_k are diagonal with independent entries, Z\mat{Z} is diagonal and ∥Z∥\norm{\mat{Z}} the maximum absolute value of dd independent scalar sums. The maximal inequality bounds that maximum by log⁡d\sqrt{\log d} times each sum’s scale, and independent variables (e.g. Gaussian) attain log⁡d\sqrt{\log d}. Remarkably the noncommutative case is no worse than diagonal.

Proof

It suffices to bound P(λmax⁡(Z)≥t)≤dexp⁡(⋯ )\Pr(\lambda_{\max}(\mat{Z}) \ge t) \le d\exp(\cdots); applying it to −Z-\mat{Z} gives the lower tail, and their union gives 2d2d. The Chernoff method proof has four pieces.

1. Matrix Laplace transform. For θ>0\theta > 0, eθλmax⁡(Z)=λmax⁡(eθZ)≤tr⁡eθZe^{\theta\lambda_{\max}(\mat{Z})} = \lambda_{\max}(e^{\theta\mat{Z}}) \le \tr e^{\theta\mat{Z}}, since eθZe^{\theta\mat{Z}} is positive definite and its largest eigenvalue is at most their sum. Markov gives

P(λmax⁡(Z)≥t)≤e−θt Etr⁡eθZ.\Pr\big(\lambda_{\max}(\mat{Z}) \ge t\big) \le e^{-\theta t}\,\E\tr e^{\theta\mat{Z}}.

2. Cumulant subadditivity (Lieb). In the scalar case Eeθ∑Xk=∏kEeθXk\E e^{\theta\sum X_k} = \prod_k\E e^{\theta X_k}. For matrices eA+B≠eAeBe^{\mat{A} + \mat{B}} \neq e^{\mat{A}}e^{\mat{B}} if they do not commute, so factorization fails. Lieb’s deep theorem (1973) substitutes: for fixed symmetric H\mat{H}, function A↦tr⁡exp⁡(H+log⁡A)\mat{A} \mapsto \tr\exp(\mat{H} + \log\mat{A}) is concave on positive-definite matrices. Jensen applied to A=eY\mat{A} = e^{\mat{Y}} gives Etr⁡exp⁡(H+Y)≤tr⁡exp⁡(H+log⁡EeY)\E\tr\exp(\mat{H} + \mat{Y}) \le \tr\exp(\mat{H} + \log\E e^{\mat{Y}}); applying it summand by summand (conditioning on the independent others),

Etr⁡eθZ≤tr⁡exp⁡(∑klog⁡EeθXk).\E\tr e^{\theta\mat{Z}} \le \tr\exp\Big(\sum_k \log\E e^{\theta\mat{X}_k}\Big).

3. Each summand’s generating function. Let φ(x)=(eθx−θx−1)/x2\varphi(x) = (e^{\theta x} - \theta x - 1)/x^2, an increasing function. Since eigenvalues of Xk\mat{X}_k are ≤L\le L, apply scalar inequality φ(x)≤φ(L)\varphi(x) \le \varphi(L) eigenvalue by eigenvalue:

eθXk=I+θXk+φ(Xk)Xk2⪯I+θXk+φ(L)Xk2,e^{\theta\mat{X}_k} = \mat{I} + \theta\mat{X}_k + \varphi(\mat{X}_k)\mat{X}_k^2 \preceq \mat{I} + \theta\mat{X}_k + \varphi(L)\mat{X}_k^2,

where ⪯\preceq is Loewner order (A⪯B\mat{A} \preceq \mat{B} if B−A\mat{B} - \mat{A} is positive semidefinite). Using k!≥2⋅3k−2k! \ge 2\cdot 3^{k-2} in the eθLe^{\theta L} series gives φ(L)≤g(θ):=θ2/21−θL/3\varphi(L) \le g(\theta) := \frac{\theta^2/2}{1 - \theta L/3} for 0<θ<3/L0 < \theta < 3/L. Taking expectations using EXk=0\E\mat{X}_k = \mat{0} and I+A⪯eA\mat{I} + \mat{A} \preceq e^{\mat{A}}:

EeθXk⪯I+g(θ) EXk2⪯exp⁡(g(θ) EXk2).\E e^{\theta\mat{X}_k} \preceq \mat{I} + g(\theta)\,\E\mat{X}_k^2 \preceq \exp\big(g(\theta)\,\E\mat{X}_k^2\big).

The logarithm is monotone in Loewner order, so log⁡EeθXk⪯g(θ) EXk2\log\E e^{\theta\mat{X}_k} \preceq g(\theta)\,\E\mat{X}_k^2.

4. Finish. tr⁡exp⁡\tr\exp is also monotone, so

Etr⁡eθZ≤tr⁡exp⁡(g(θ)∑kEXk2)≤d eg(θ)v,\E\tr e^{\theta\mat{Z}} \le \tr\exp\Big(g(\theta)\sum_k\E\mat{X}_k^2\Big) \le d\,e^{g(\theta)v},

because an d×dd\times d matrix with eigenvalues ≤g(θ)v\le g(\theta)v has exponential trace ≤d eg(θ)v\le d\,e^{g(\theta)v}. This leaves P(λmax⁡≥t)≤dexp⁡(−θt+g(θ)v)\Pr(\lambda_{\max} \ge t) \le d\exp(-\theta t + g(\theta)v). With θ=t/(v+Lt/3)\theta = t/(v + Lt/3), 1−θL/3=v/(v+Lt/3)1 - \theta L/3 = v/(v + Lt/3), so g(θ)v=t22(v+Lt/3)g(\theta)v = \frac{t^2}{2(v + Lt/3)} and exponent −t2/2v+Lt/3-\frac{t^2/2}{v + Lt/3}. The expectation bound uses the same pieces without passing through the tail: by Jensen θ Eλmax⁡(Z)≤log⁡Eeθλmax⁡(Z)≤log⁡Etr⁡eθZ≤log⁡d+g(θ)v\theta\,\E\lambda_{\max}(\mat{Z}) \le \log\E e^{\theta\lambda_{\max}(\mat{Z})} \le \log\E\tr e^{\theta\mat{Z}} \le \log d + g(\theta)v, divide by θ\theta and optimize θ∈(0,3/L)\theta \in (0, 3/L), giving 2vlog⁡d+13Llog⁡d\sqrt{2v\log d} + \tfrac13L\log d. For ∥Z∥\norm{\mat{Z}} apply this to block-diagonal matrix 2d×2d2d\times 2d with blocks Z\mat{Z} and −Z-\mat{Z}, whose largest eigenvalue is ∥Z∥\norm{\mat{Z}} and which has the same LL and vv: hence log⁡(2d)\log(2d).

∎

Samples needed to estimate covariance

The central application is sample covariance. If x1,…,xn\vb{x}_1, \dots, \vb{x}_n are independent copies of centered vector x\vb{x} with Exx⊤=Σ\E\vb{x}\vb{x}\T = \mat{\Sigma}, then Σ^−Σ=∑k(xkxk⊤−Σ)/n\hat{\mat{\Sigma}} - \mat{\Sigma} = \sum_k (\vb{x}_k\vb{x}_k\T - \mat{\Sigma})/n is exactly a sum as in the theorem.

This is covariance estimation error in its cleanest form; the final guided exercise proves it in three lines using matrix Bernstein. The reading matters. Write m=r∥Σ∥m = r\norm{\mat{\Sigma}}. Since E∥x∥2=tr⁡Σ\E\norm{\vb{x}}^2 = \tr\mat{\Sigma}, rr is at least effective rank tr⁡Σ/∥Σ∥\tr\mat{\Sigma}/\norm{\mat{\Sigma}}, equal to dd if Σ=I\mat{\Sigma} = \mat{I} and much smaller if variance is concentrated in a few directions. For relative error ∥Σ^−Σ∥≤ε∥Σ∥\norm{\hat{\mat{\Sigma}} - \mat{\Sigma}} \le \eps\norm{\mat{\Sigma}} it suffices that

n≳rlog⁡dε2.n \gtrsim \frac{r\log d}{\eps^2}.

For isotropic data in d=1000d = 1000 and ε=0.1\eps = 0.1, theorem constants require about 1.61.6 million samples: the leading term is 2dlog⁡(2d)/ε2≈1.5×1062d\log(2d)/\eps^2 \approx 1.5\times 10^6. Effective-rank-10 covariance needs many fewer independently of dd except logarithmically: why PCA works in enormous dimensions when signal has low rank.

Is log⁡d\log d necessary? It depends. If x=d eJ\vb{x} = \sqrt d\,\vb{e}_J with JJ uniform in {1,…,d}\{1, \dots, d\} (coordinate sampling), Σ=I\mat{\Sigma} = \mat{I}, m=dm = d, and Σ^\hat{\mat{\Sigma}} is diagonal with entries d Nj/nd\,N_j/n, where NjN_j counts occurrences of coordinate jj. Error is the maximum of dd binomial deviations, and this maximum does have log⁡d\sqrt{\log d}. For Gaussian or sphere-uniform data the bound is pessimistic by that factor: the next section gives the exact answer without the logarithm. The lab measures it.

Extreme singular values of Gaussian matrices

Let G∈Rn×d\mat{G} \in \R^{n\times d}, n≥dn \ge d have independent N(0,1)\Normal(0, 1) entries. Its singular values smin⁡(G)≤⋯≤smax⁡(G)s_{\min}(\mat{G}) \le \cdots \le s_{\max}(\mat{G}) control what matters: smax⁡2/ns_{\max}^2/n and smin⁡2/ns_{\min}^2/n are the largest and smallest eigenvalues of isotropic sample covariance Σ^=G⊤G/n\hat{\mat{\Sigma}} = \mat{G}\T\mat{G}/n. Since E∥Gu∥2=n\E\norm{\mat{G}\vb{u}}^2 = n for every unit u\vb{u}, one expects s≈ns \approx \sqrt n in every direction. The correction is exactly ±d\pm\sqrt d.

This is the extreme singular values result. Its ingredients: expectations Esmax⁡≤n+d\E s_{\max} \le \sqrt n + \sqrt d and Esmin⁡≥n−d\E s_{\min} \ge \sqrt n - \sqrt d from Slepian and Gordon Gaussian comparison inequalities (Davidson and Szarek, 2001), and immediate concentration around them: G↦smax⁡(G)\mat{G} \mapsto s_{\max}(\mat{G}) and G↦smin⁡(G)\mat{G} \mapsto s_{\min}(\mat{G}) are 1-Lipschitz in Frobenius norm (Weyl inequalities, ∣si(A)−si(B)∣≤∥A−B∥≤∥A−B∥F\abs{s_i(\mat{A}) - s_i(\mat{B})} \le \norm{\mat{A} - \mat{B}} \le \norm{\mat{A} - \mat{B}}_F), so Gaussian concentration for Lipschitz functions gives tails e−t2/2e^{-t^2/2}.

Gordon’s inequalities are not proved here, but an ε-net yields the correct order and exemplifies random matrix norm bounds.

Proof

(Upper bound with nonoptimal constant.) Let N\mathcal{N} and M\mathcal{M} be 14\tfrac14-nets of spheres Sd−1S^{d-1} and Sn−1S^{n-1}, with ∣N∣≤9d\abs{\mathcal{N}} \le 9^d and ∣M∣≤9n\abs{\mathcal{M}} \le 9^n, existing by lesson 22’s volume argument.

Step 1: control norm on the net. Let unit vectors u∗,v∗\vb{u}^*, \vb{v}^* satisfy v∗TGu∗=∥G∥\vb{v}^{*\mathsf{T}}\mat{G}\vb{u}^* = \norm{\mat{G}}, with u∈N\vb{u} \in \mathcal{N}, v∈M\vb{v} \in \mathcal{M} at distance ≤14\le \tfrac14 from them. Then

∥G∥−v⊤Gu=(v∗−v)⊤Gu∗+v⊤G(u∗−u)≤14∥G∥+14∥G∥,\norm{\mat{G}} - \vb{v}\T\mat{G}\vb{u} = (\vb{v}^* - \vb{v})\T\mat{G}\vb{u}^* + \vb{v}\T\mat{G}(\vb{u}^* - \vb{u}) \le \tfrac14\norm{\mat{G}} + \tfrac14\norm{\mat{G}},

so ∥G∥≤2max⁡u∈N,v∈Mv⊤Gu\norm{\mat{G}} \le 2\max_{\vb{u} \in \mathcal{N}, \vb{v} \in \mathcal{M}}\vb{v}\T\mat{G}\vb{u}.

Step 2: each net point is Gaussian. For fixed unit u,v\vb{u}, \vb{v}, v⊤Gu=∑ijviujGij∼N(0,1)\vb{v}\T\mat{G}\vb{u} = \sum_{ij}v_iu_jG_{ij} \sim \Normal(0, 1), because ∑ijvi2uj2=1\sum_{ij}v_i^2u_j^2 = 1.

Step 3: union. P(max⁡N×Mv⊤Gu>s)≤9n+de−s2/2\Pr\big(\max_{\mathcal{N}\times\mathcal{M}}\vb{v}\T\mat{G}\vb{u} > s\big) \le 9^{n+d}e^{-s^2/2}. With s=2log⁡9 (n+d)+ts = \sqrt{2\log 9\,(n + d)} + t the right side is ≤e−t2/2\le e^{-t^2/2}, and since n+d≤n+d\sqrt{n + d} \le \sqrt n + \sqrt d,

∥G∥≤22log⁡9 (n+d)+2t≈4.2 (n+d)+2t\norm{\mat{G}} \le 2\sqrt{2\log 9}\,(\sqrt n + \sqrt d) + 2t \approx 4.2\,(\sqrt n + \sqrt d) + 2t

with probability at least 1−e−t2/21 - e^{-t^2/2}.

∎

The net gives order n+d\sqrt n + \sqrt d with a constant 4 times worse than the true one; Gordon gives constant 1. For smin⁡s_{\min} the net argument also works (lower-bound ∥Gu∥\norm{\mat{G}\vb{u}} at every net point and use the upper bound to cover the sphere). Arbitrary independent isotropic sub-Gaussian rows admit a version with constants: n−CK2(d+t)≤smin⁡≤smax⁡≤n+CK2(d+t)\sqrt n - CK^2(\sqrt d + t) \le s_{\min} \le s_{\max} \le \sqrt n + CK^2(\sqrt d + t), where KK is the rows’ sub-Gaussian norm (Vershynin, High-Dimensional Probability, theorem 4.6.1).

Divide by n\sqrt n and square for the desired consequence. With γ=d/n\gamma = d/n and probability ≥1−2e−t2/2\ge 1 - 2e^{-t^2/2}, all eigenvalues of Σ^=G⊤G/n\hat{\mat{\Sigma}} = \mat{G}\T\mat{G}/n lie in

[(1−γ−t/n)2, (1+γ+t/n)2],luego∥Σ^−I∥≤2δ+δ2,δ=γ+tn.\Big[\big(1 - \sqrt\gamma - t/\sqrt n\big)^2,\ \big(1 + \sqrt\gamma + t/\sqrt n\big)^2\Big], \qquad\text{luego}\qquad \norm{\hat{\mat{\Sigma}} - \mat{I}} \le 2\delta + \delta^2,\quad \delta = \sqrt\gamma + \tfrac{t}{\sqrt n}.

For Gaussian data covariance error is ≈2d/n\approx 2\sqrt{d/n}, without Bernstein’s log⁡d\log d. Extremes (1±γ)2(1 \pm \sqrt\gamma)^2 are exactly the first histogram’s edges. Marchenko-Pastur describes what lies between.

[ ]Extreme singular values versus √n ± √dBrowser
import numpy as np

rng = np.random.default_rng(0)
print("   n     d   s_min   √n−√d    s_max   √n+√d   cota de la red 4.2(√n+√d)")
for n, d in [(100, 10), (400, 100), (800, 200), (1000, 50), (300, 300)]:
    G = rng.standard_normal((n, d))
    s = np.linalg.svd(G, compute_uv=False)
    print(f"{n:5d} {d:5d}  {s.min():6.2f}  {np.sqrt(n) - np.sqrt(d):6.2f}   {s.max():6.2f}  {np.sqrt(n) + np.sqrt(d):6.2f}   {4.2 * (np.sqrt(n) + np.sqrt(d)):7.1f}")

# las fluctuaciones alrededor de √n + √d son O(1), no O(√n): 20 réplicas con n = 400, d = 100
smax = [np.linalg.svd(rng.standard_normal((400, 100)), compute_uv=False)[0] for _ in range(20)]
print(f"\ns_max en 20 réplicas: media {np.mean(smax):.3f}, desviación típica {np.std(smax):.3f}  (√n + √d = 30)")

In the last, square row, smin⁡s_{\min} nearly vanishes, as n−d=0\sqrt n - \sqrt d = 0 predicts. A square Gaussian matrix is invertible but ill-conditioned; its smallest singular value is of order 1/n1/\sqrt n (Edelman, 1988). Across replicates smax⁡s_{\max} stays slightly below n+d\sqrt n + \sqrt d with small fluctuations: a theoretical surprise discussed at the edge.

Wigner’s semicircle law

Move from bounds to limit laws. The simplest object is a symmetric matrix with independent entries.

Why 1/n1/\sqrt n? Because 1ntr⁡W2=1n2∑ijXij2→1\frac1n\tr\mat{W}^2 = \frac1{n^2}\sum_{ij}X_{ij}^2 \to 1: the mean of λi2\lambda_i^2 is 1, so eigenvalues are order 1. With 1/n1/n they would all tend to 0; unnormalized they spread as n\sqrt n. This is the commonest scaling mistake here.

Wigner’s semicircle law says that the eigenvalue histogram of one large matrix is deterministic: it does not fluctuate with the sample. It depends on the entry law only through variance.

InteractiveThe semicircle emerges
Eigenvalues of W\mat{W} (100×100, Gaussian entries)
calculating eigenvalues…
  • eigenvalue histogram (density)
  • semicircle 4−x2/2π\sqrt{4 - x^2}/2\pi
Moment 1Ntr⁡W2k\tfrac1N\tr\mat{W}^{2k} divided by Catalan CkC_k
  • ratio 1: moment equals CkC_k
100
Entries
Normalization
Matrices averagedcalculating…
Largest ∣λ∣\abs{\lambda} (mean per matrix); limit 2…
1Ntr⁡W2\tfrac1N\tr\mat{W}^2; limit C1=1C_1 = 1…
1Ntr⁡W4\tfrac1N\tr\mat{W}^4; limit C2=2C_2 = 2…
1Ntr⁡W6\tfrac1N\tr\mat{W}^6; limit C3=5C_3 = 5…
Outside axis [−3,3][-3, 3]…
Matrices W=X/N\mat{W} = \mat{X}/\sqrt N with variance-1 entries. For small NN aggregate several matrices to obtain about 1600 eigenvalues, so the histogram estimates the mean density at that size; at N=400N = 400 four matrices suffice. Right: even moments 1Ntr⁡W2k\frac1N\tr\mat{W}^{2k} divided by Catalan numbers 1,2,5,141, 2, 5, 14: the moment method says ratios tend to 1. Switch among Gaussian, Rademacher (±1\pm 1) and uniform: the limit is universal. Then try infinite-variance heavy tails and normalizations 1/N1/N and ‘none’.

Moment method: Dyck paths

The classical proof counts. Since ∫xk  ⁣dμW=1n∑iλik=1ntr⁡Wk\int x^k\,\dd\mu_{\mat{W}} = \frac1n\sum_i\lambda_i^k = \frac1n\tr\mat{W}^k, spectral distribution moments are traces of powers, and traces are index sums:

1nEtr⁡Wk=1n1+k/2∑i1,…,ik=1nE[Xi1i2Xi2i3⋯Xiki1].\frac1n\E\tr\mat{W}^k = \frac{1}{n^{1 + k/2}}\sum_{i_1, \dots, i_k = 1}^n \E\big[X_{i_1i_2}X_{i_2i_3}\cdots X_{i_ki_1}\big].

Each term is a closed walk i1→i2→⋯→ik→i1i_1 \to i_2 \to \cdots \to i_k \to i_1 of kk steps in the complete graph on {1,…,n}\{1, \dots, n\}; its expectation depends only on how often each edge is traversed. Three observations decide everything:

  1. Every edge must be traversed at least twice. If edge {a,b}\{a, b\} appears once, factor XabX_{ab} is independent of the rest and has mean 0: the term vanishes.
  2. There are at most k/2k/2 distinct edges and, since the walk is connected, at most k/2+1k/2 + 1 distinct vertices. The number of walks with vv vertices is O(nv)\bigO(n^v), so after division by n1+k/2n^{1 + k/2} only exactly k/2+1k/2 + 1 vertices survive. In particular, if kk is odd nothing survives: odd moments tend to 0.
  3. Survivors are trees traversed twice. A connected graph with k/2k/2 edges and k/2+1k/2 + 1 vertices is a tree, and a closed walk crossing each tree edge exactly twice is a depth-first traversal: down once, up once. Each contributes ∏EXab2=1\prod\E X_{ab}^2 = 1.

Encode the traversal by recording +1+1 going down and −1-1 going up: this gives kk steps ±1\pm 1, starting and ending at 0 and never below 0. This is a Dyck path; the number of Dyck paths of length 2j2j is Catalan number Cj=1j+1(2jj)C_j = \frac{1}{j+1}\binom{2j}{j}. Each shape admits n(n−1)⋯(n−j)∼nj+1n(n-1)\cdots(n - j) \sim n^{j+1} vertex labelings, so

1nEtr⁡W2j⟶Cj,1nEtr⁡W2j+1⟶0.\frac1n\E\tr\mat{W}^{2j} \longrightarrow C_j, \qquad \frac1n\E\tr\mat{W}^{2j+1} \longrightarrow 0.

The first are 1,2,5,14,421, 2, 5, 14, 42. To see they are semicircle moments, with x=2sin⁡θx = 2\sin\theta, ∫x2jρsc(x)  ⁣dx=22j+1π∫−π/2π/2sin⁡2jθcos⁡2θ  ⁣dθ=Cj\int x^{2j}\rho_{sc}(x)\,\dd x = \frac{2^{2j+1}}{\pi}\int_{-\pi/2}^{\pi/2}\sin^{2j}\theta\cos^2\theta\,\dd\theta = C_j, a beta integral. The guided exercise counts case k=4k = 4 by hand.

Two standard steps turn expected-moment convergence into the theorem. First variance: similar counting shows Var⁡(1ntr⁡Wk)=O(1/n2)\Var\big(\frac1n\tr\mat{W}^k\big) = \bigO(1/n^2) (supporting path pairs must share an edge, costing two vertices), so Chebyshev and Borel-Cantelli make μW\mu_{\mat{W}} moments converge almost surely. Second, the compactly supported semicircle is determined by its moments, so moment convergence implies weak convergence. If entries only have finite variance rather than all moments, truncate and control error using Hoffman-Wielandt (Anderson, Guionnet and Zeitouni, chapter 2).

Universality and its limits

Counting used only EXab=0\E X_{ab} = 0 and EXab2=1\E X_{ab}^2 = 1: this is universality. It has precise limits:

  • Infinite variance. For power tails P(∣X∣>x)∼x−α\Pr(\abs{X} > x) \sim x^{-\alpha}, α<2\alpha < 2, the correct normalization is n1/αn^{1/\alpha}, not n\sqrt n, and the limit is another heavy-tailed law (Lévy matrices, Ben Arous and Guionnet, 2008), related to stable laws. This appears in the heavy-tail option.
  • The edge needs more than density. The largest eigenvalue converges to 2 iff entries have a finite fourth moment (Bai and Yin, 1988). With finite variance but infinite fourth moment, the histogram converges to semicircle while a few eigenvalues escape to infinity.
  • Dependence. If entries are no longer independent (covariance matrices, matrix products, network Jacobians), shape changes. The next law is the first example.

The Stieltjes transform (idea)

The moment method is elementary but rigid. The flexible tool is the Stieltjes transform of measure μ\mu,

sμ(z)=∫ ⁣dμ(x)x−z,z∈C, Im⁡z>0,s_\mu(z) = \int\frac{\dd\mu(x)}{x - z}, \qquad z \in \C,\ \operatorname{Im} z > 0,

which for the spectral distribution is the resolvent’s normalized trace sμW(z)=1ntr⁡(W−zI)−1s_{\mu_{\mat{W}}}(z) = \frac1n\tr(\mat{W} - z\mat{I})\inv. Density is recovered by inversion: ρ(x)=lim⁡η↓01πIm⁡sμ(x+iη)\rho(x) = \lim_{\eta \downarrow 0}\frac1\pi\operatorname{Im}s_\mu(x + i\eta). The semicircle has a one-line derivation. By the Schur complement formula, the first resolvent diagonal entry is

[(W−z)−1]11=1W11−z−w⊤(W(1)−z)−1w,\big[(\mat{W} - z)\inv\big]_{11} = \frac{1}{W_{11} - z - \vb{w}\T(\mat{W}^{(1)} - z)\inv\vb{w}},

where w\vb{w} is the first column without its first entry and W(1)\mat{W}^{(1)} is W\mat{W} without its first row and column. W11=O(n−1/2)W_{11} = \bigO(n^{-1/2}) is negligible, and w\vb{w} is independent of W(1)\mat{W}^{(1)} with variance-1/n1/n entries, so the quadratic form concentrates at 1ntr⁡(W(1)−z)−1≈s(z)\frac1n\tr(\mat{W}^{(1)} - z)\inv \approx s(z) (lesson 22’s norm concentration, now for quadratic forms). Averaging nn diagonal entries gives s=1/(−z−s)s = 1/(-z - s), i.e.

s(z)2+z s(z)+1=0⟹s(z)=−z+z2−42,s(z)^2 + z\,s(z) + 1 = 0 \quad\Longrightarrow\quad s(z) = \frac{-z + \sqrt{z^2 - 4}}{2},

and the imaginary part on the real axis is 4−x2/2\sqrt{4 - x^2}/2: the semicircle without counting paths. This self-consistency technique generalizes to covariances, multilayer models and most current research calculations.

Marchenko-Pastur law

Return to the motivating sample covariance. Now X∈Rn×d\mat{X} \in \R^{n\times d} has rows xi⊤\vb{x}_i\T with independent entries of mean 0 and variance σ2\sigma^2, and Σ^=X⊤X/n\hat{\mat{\Sigma}} = \mat{X}\T\mat{X}/n is d×dd\times d.

This is the Marchenko-Pastur law. The continuous-density interval [λ−,λ+][\lambda_-, \lambda_+] and eigenvalues inside are called the spectral bulk; anything above λ+\lambda_+ needs explanation. The atom is linear algebra: with d>nd > n, Σ^\hat{\mat{\Sigma}} has rank nn and d−nd - n zero eigenvalues. Edges λ±\lambda_\pm are those of the extreme-singular-value theorem, and γ→0\gamma \to 0 recovers the classical regime: support [(1−γ)2,(1+γ)2][(1 - \sqrt\gamma)^2, (1 + \sqrt\gamma)^2] shrinks toward 1 with width 4γ4\sqrt\gamma.

The first two moments can be calculated by hand and explain the first figure’s spread. With σ2=1\sigma^2 = 1 and Gaussian data, 1dEtr⁡Σ^=1\frac1d\E\tr\hat{\mat{\Sigma}} = 1, and

1dEtr⁡Σ^2=1dn2∑i,jE(xi⊤xj)2=1dn2[n E∥x∥4+n(n−1) d]=n(d2+2d)+n(n−1)ddn2=1+d+1n.\frac1d\E\tr\hat{\mat{\Sigma}}^2 = \frac{1}{dn^2}\sum_{i,j}\E\big(\vb{x}_i\T\vb{x}_j\big)^2 = \frac{1}{dn^2}\Big[n\,\E\norm{\vb{x}}^4 + n(n-1)\,d\Big] = \frac{n(d^2 + 2d) + n(n-1)d}{dn^2} = 1 + \frac{d + 1}{n}.

Eigenvalue variance around mean 1 is d+1n→γ\frac{d+1}{n} \to \gamma. With γ=0.5\gamma = 0.5 this is standard deviation 0.710.71 around a true value with no spread. No method inspecting individual eigenvalues can ignore it.

The Marchenko-Pastur Stieltjes transform follows from the same self-consistency argument and satisfies, with σ2=1\sigma^2 = 1,

γz s(z)2+(z−1+γ) s(z)+1=0.\gamma z\,s(z)^2 + (z - 1 + \gamma)\,s(z) + 1 = 0.

The discriminant is (z−1+γ)2−4γz=(z−λ+)(z−λ−)(z - 1 + \gamma)^2 - 4\gamma z = (z - \lambda_+)(z - \lambda_-), and the correct root’s imaginary part at real z=xz = x gives exactly ρMP\rho_{MP}. The lab checks this numerically by solving at x+iηx + i\eta with small η\eta.

A consequence: the double-descent peak

Marchenko-Pastur’s first inverse moment is ∫x−1  ⁣dρMP=11−γ\int x\inv\,\dd\rho_{MP} = \frac{1}{1 - \gamma} for γ<1\gamma < 1, and explodes as γ→1\gamma \to 1 because lower edge (1−γ)2(1 - \sqrt\gamma)^2 reaches 0. This directly affects regression. With y=Xβ+ε\vb{y} = \mat{X}\vb{\beta} + \vb{\eps}, noise variance σ2\sigma^2 and isotropic Gaussian rows, least squares satisfies E∥β^−β∥2=σ2Etr⁡(X⊤X)−1=σ2dn−d−1\E\norm{\hat{\vb{\beta}} - \vb{\beta}}^2 = \sigma^2\E\tr(\mat{X}\T\mat{X})\inv = \sigma^2\frac{d}{n - d - 1} by inverse-Wishart expectation, tending to

σ2 γ1−γ.\sigma^2\,\frac{\gamma}{1 - \gamma}.

Estimation error diverges at interpolation threshold d=nd = n even for a correct model and moderate noise. For γ>1\gamma > 1 infinitely many solutions exist, and the minimum-norm interpolator has risk ∥β∥2(1−1/γ)+σ2/(γ−1)\norm{\vb{\beta}}^2(1 - 1/\gamma) + \sigma^2/(\gamma - 1), which falls again: double descent in its simplest form (Hastie, Montanari, Rosset and Tibshirani, 2022). The final section simulates the full curve.

Spiked models and the BBP transition

So far pure noise. Now add signal: xi∼iidN(0,Σ)\vb{x}_i \iid \Normal(\vb{0}, \mat{\Sigma}) with

Σ=I+β uu⊤,∥u∥=1, β>0.\mat{\Sigma} = \mat{I} + \beta\,\vb{u}\vb{u}\T, \qquad \norm{\vb{u}} = 1,\ \beta > 0.

Variance in direction u\vb{u} is 1+β1 + \beta; in others it is 1. This is Johnstone’s (2001) spiked covariance model, and PCA asks whether the largest eigenvalue of Σ^\hat{\mat{\Sigma}} reveals the spike and its eigenvector points to u\vb{u}. In fixed dimension, yes for any β>0\beta > 0 given enough nn. With d/n→γd/n \to \gamma the answer is a phase transition.

This is the BBP phase transition. Baik, Ben Arous and Péché proved it for complex data via largest-eigenvalue fluctuations; Baik and Silverstein (2006) gave real-data limits, and Paul (2007) the eigenvector limit. Below threshold the spike is spectrally invisible: the largest eigenvalue behaves as without signal and the top eigenvector is nearly orthogonal to u\vb{u}.

InteractiveThe BBP transition
Eigenvalues of Σ^\hat{\mat{\Sigma}} with Σ=I+β e1e1⊤\mat{\Sigma} = \mat{I} + \beta\,\vb{e}_1\vb{e}_1\T
calculating…
  • eigenvalues of Σ^\hat{\mat{\Sigma}}
  • Marchenko–Pastur and its edge
  • largest eigenvalue
  • BBP prediction
Overlap ⟨v^1,e1⟩2\langle\hat{\vb{v}}_1, \vb{e}_1\rangle^2 versus β\beta
√γinvisible
  • simulation (each visited β)
  • limit (1−γ/β2)/(1+γ/β)(1 - \gamma/\beta^2)/(1 + \gamma/\beta)
1.50
0.50
Dimension and BBP threshold γ\sqrt\gammad = 200; 0.707
Largest eigenvalue λ^1\hat\lambda_1; prediction…
Bulk edge (1+γ)2(1 + \sqrt\gamma)^22.914
(λ^1−μTW)/σTW(\hat\lambda_1 - \mu_{TW})/\sigma_{TW} (above 2 is rare without signal)…
Overlap ⟨v^1,e1⟩2\langle\hat{\vb{v}}_1, \vb{e}_1\rangle^2; prediction…
β=1.50>γ\beta = 1.50 > \sqrt\gamma: the spike leaves the bulk and PCA sees the signal, though with overlap 0.58, not 1.
Data with Σ=I+βe1e1⊤\mat{\Sigma} = \mat{I} + \beta\vb{e}_1\vb{e}_1\T, n=400n = 400, d=γnd = \gamma n. The same noise is used for all β\beta (only coordinate 1 is rescaled), so the slider evolves one spectrum. Left: largest eigenvalue (red) and limiting prediction (hollow). Right: overlap ⟨v^1,e1⟩2\langle\hat{\vb{v}}_1, \vb{e}_1\rangle^2 of the first principal component with signal versus β\beta, with limiting curve zero until γ\sqrt\gamma and positive after. Each visited β\beta leaves a point; ‘Sweep β\beta’ plots all. Compare γ=0.2\gamma = 0.2 and γ=1\gamma = 1, especially near the finite-size threshold.

Where the threshold comes from

The cleanest mechanism is the additive Wigner analogue, fully derived with the Stieltjes transform. Let M=W+θuu⊤\mat{M} = \mat{W} + \theta\vb{u}\vb{u}\T with Wigner W\mat{W}, θ>0\theta > 0 and fixed unit vector u\vb{u}. A number λ\lambda outside [−2,2][-2, 2] (hence for large nn outside the spectrum of W\mat{W}) is an eigenvalue of M\mat{M} iff

det⁡(W−λ+θuu⊤)=0  ⟺  1+θ u⊤(W−λ)−1u=0  ⟺  u⊤(λ−W)−1u=1θ,\det(\mat{W} - \lambda + \theta\vb{u}\vb{u}\T) = 0 \iff 1 + \theta\,\vb{u}\T(\mat{W} - \lambda)\inv\vb{u} = 0 \iff \vb{u}\T(\lambda - \mat{W})\inv\vb{u} = \frac1\theta,

by the rank-one perturbation determinant lemma. As before, the quadratic form concentrates on normalized trace: u⊤(λ−W)−1u→G(λ):=−ssc(λ)=λ−λ2−42\vb{u}\T(\lambda - \mat{W})\inv\vb{u} \to G(\lambda) := -s_{sc}(\lambda) = \frac{\lambda - \sqrt{\lambda^2 - 4}}{2} for λ>2\lambda > 2. And GG decreases on (2,∞)(2, \infty), with G(2)=1G(2) = 1 and G(∞)=0G(\infty) = 0. Equation G(λ)=1/θG(\lambda) = 1/\theta has a solution outside the bulk iff 1/θ<11/\theta < 1, then λ=θ+1/θ\lambda = \theta + 1/\theta. If θ≤1\theta \le 1, the perturbation cannot produce an outlier: GG is bounded by its edge value, whose finiteness sets the threshold.

For covariance the same argument with Marchenko-Pastur’s transform gives threshold γ\sqrt\gamma. An elegant check: function f(β)=(1+β)(1+γ/β)=1+γ+β+γ/βf(\beta) = (1 + \beta)(1 + \gamma/\beta) = 1 + \gamma + \beta + \gamma/\beta attains its minimum exactly at β=γ\beta = \sqrt\gamma, where it equals (1+γ)2(1 + \sqrt\gamma)^2, the edge. Increasing branch β>γ\beta > \sqrt\gamma is the isolated eigenvalue; the decreasing branch corresponds to nothing, since an eigenvalue cannot move away from bulk as signal weakens.

Three practical consequences:

  • Detecting a spike requires n>d/β2n > d/\beta^2. A direction with 50% more variance (β=0.5\beta = 0.5) in d=1000d = 1000 needs more than 40004000 samples for PCA to see it, many more to see it well.
  • Seeing is not accurate estimation. Just above threshold overlap is small: with γ=0.5\gamma = 0.5 and β=1\beta = 1 it is 1/31/3, an angle of about 55°55° to truth. The eigenvalue is biased upward: it estimates (1+β)(1+γ/β)(1 + \beta)(1 + \gamma/\beta), not 1+β1 + \beta. Inverting this formula underlies covariance shrinkage (Donoho, Gavish and Johnstone, 2018), linked to covariance cleaning and random-matrix cleaning in finance.
  • Choosing how many components to keep has a principled answer: those sufficiently above Marchenko-Pastur’s edge, the idea of PCA rank selection against noise.

Edge fluctuations and finite-size validity

The previous laws are asymptotic. How far does the largest eigenvalue move at finite size? Much less than the CLT suggests. For a GOE matrix (Gaussian, variance 1 off-diagonal and 2 on it),

n2/3(λmax⁡(W)−2)→dTW1,n^{2/3}\big(\lambda_{\max}(\mat{W}) - 2\big) \xrightarrow{d} \mathrm{TW}_1,

the Tracy-Widom distribution (1996), non-Gaussian, asymmetric, with mean −1.21-1.21 and standard deviation 1.271.27. For sample covariance, Johnstone (2001) proved an analogue with centering μn,d=(n−1+d)2/n\mu_{n,d} = (\sqrt{n-1} + \sqrt d)^2/n and scale σn,d=(n−1+d)(1n−1+1d)1/3/n\sigma_{n,d} = (\sqrt{n-1} + \sqrt d)\big(\tfrac{1}{\sqrt{n-1}} + \tfrac{1}{\sqrt d}\big)^{1/3}/n. The 99% quantile of TW1\mathrm{TW}_1 is 2.022.02, yielding a principled signal test: for n=400n = 400 and d=200d = 200, μ=2.910\mu = 2.910, σ=0.042\sigma = 0.042, an eigenvalue above 2.9952.995 is significant at 1%. Universality extends here: the same fluctuations hold for non-Gaussian sufficiently light-tailed entries (Soshnikov, 1999; Tao and Vu, 2010; Erdős and Yau).

Two scales coexist and are easily confused. The edge fluctuates as n−2/3n^{-2/3}; an isolated eigenvalue above BBP fluctuates as n−1/2n^{-1/2}, Gaussian. Near threshold, with β−γ\beta - \sqrt\gamma of order n−1/3n^{-1/3}, they mix: the BBP figure’s region where simulations depart from the limit curve.

The next cell calculates the GOE largest-eigenvalue law without building a dense matrix. Dumitriu and Edelman (2002) proved GOE has the same eigenvalues as a tridiagonal matrix with diagonal N(0,2)\Normal(0, 2) and subdiagonal χn−1,χn−2,…,χ1\chi_{n-1}, \chi_{n-2}, \dots, \chi_1; its largest eigenvalue is found by bisection using Sturm sequences, vectorized across thousands of replicates.

[ ]Tracy-Widom with the tridiagonal modelBrowser
import numpy as np

rng = np.random.default_rng(1)

def lmax_goe(n, reps):
    """Mayor autovalor de reps matrices GOE n×n, vía el modelo tridiagonal de Dumitriu y Edelman."""
    a = rng.normal(0, np.sqrt(2), size=(reps, n))                  # diagonal
    b2 = rng.chisquare(np.arange(n - 1, 0, -1), size=(reps, n - 1))  # subdiagonal al cuadrado
    lo = np.full(reps, 1.0 * np.sqrt(n))                           # λmax ≈ 2√n: el intervalo [√n, 3√n] lo contiene
    hi = np.full(reps, 3.0 * np.sqrt(n))
    for _ in range(32):                                            # bisección: ¿hay n autovalores por debajo de x?
        x = (lo + hi) / 2
        q = a[:, 0] - x                                            # pivotes de T − xI (recurrencia de Sturm)
        negativos = (q < 0).astype(int)
        for i in range(1, n):
            q = a[:, i] - x - b2[:, i - 1] / np.where(q == 0, 1e-300, q)
            negativos += q < 0
        todos = negativos == n
        hi = np.where(todos, x, hi)
        lo = np.where(todos, lo, x)
    return (lo + hi) / 2

for n in [25, 100, 400]:
    s = n ** (2 / 3) * (lmax_goe(n, 1000) / np.sqrt(n) - 2)
    print(f"n = {n:4d}:  n^(2/3)(λmax − 2) tiene media {s.mean():+.3f} y desviación típica {s.std():.3f}"
          f"   (Tracy-Widom: −1.21 y 1.27)")
print("\nEscala del borde para n = 400: n^(−2/3) =", round(400 ** (-2 / 3), 4), "  frente a n^(−1/2) =", 400 ** -0.5)

Mean approaches −1.21-1.21 from below, and standard deviation lies between 1.231.23 and 1.331.33, of order 1.271.27 even for small sizes (1000 replicates give sampling error about 0.03). Practically, pure-noise largest eigenvalue is below the asymptotic edge on average by about 1.2 n−2/31.2\,n^{-2/3} units; one a few hundredths above the edge with nn in the hundreds proves nothing.

Current research: double descent and weight spectra

Double descent in linear regression

The Marchenko-Pastur formula predicts the minimum-norm interpolator’s entire risk curve. The cell simulates it: n=100n = 100 data, variable dd, signal ∥β∥=1\norm{\vb{\beta}} = 1 and noise σ2=1\sigma^2 = 1.

[ ]Double descent with Marchenko-PasturBrowser
import numpy as np
import matplotlib.pyplot as plt

rng = np.random.default_rng(2)
n, sigma2, reps = 100, 1.0, 12
ds = np.array([10, 30, 50, 70, 85, 92, 97, 103, 110, 130, 160, 200, 300, 400])

def teoria(g):
    return sigma2 * g / (1 - g) if g < 1 else (1 - 1 / g) + sigma2 / (g - 1)

riesgo = []
for d in ds:
    beta = rng.standard_normal(d)
    beta /= np.linalg.norm(beta)
    err = []
    for _ in range(reps):
        X = rng.standard_normal((n, d))
        y = X @ beta + np.sqrt(sigma2) * rng.standard_normal(n)
        b = np.linalg.lstsq(X, y, rcond=None)[0]       # norma mínima si d > n
        err.append(np.sum((b - beta) ** 2))
    riesgo.append(np.median(err))
    print(f"d = {d:3d}  γ = {d / n:4.2f}   ‖β̂ − β‖² mediana {riesgo[-1]:7.2f}   límite {teoria(d / n):7.2f}")

gs = np.linspace(0.05, 4, 400)
plt.semilogy(gs, [teoria(g) for g in gs], color="gray", label="límite (Marchenko-Pastur)")
plt.semilogy(ds / n, riesgo, "o", label="simulación, n = 100")
plt.axvline(1, ls=":", color="k"); plt.xlabel("γ = d/n"); plt.ylabel("error de estimación")
plt.legend(); plt.show()

The peak at γ=1\gamma = 1 is not classical overfitting: it is the smallest eigenvalue of Σ^\hat{\mat{\Sigma}}, pushed toward 0 by edge (1−γ)2(1 - \sqrt\gamma)^2 and amplifying noise by 1/λmin⁡1/\lambda_{\min}. Any regularization moving eigenvalues from zero (ridge, early stopping) smooths the peak. Hastie and coauthors extend this to nonisotropic covariances and nonlinear random features, where the same Stieltjes machinery predicts two-layer network double descent; see learning theory.

Weight spectra of trained networks

Martin and Mahoney (2021) proposed reading training from each weight matrix’s spectrum. For W∈RN×M\mat{W} \in \R^{N\times M} (N≥MN \ge M), examine spectral density of W⊤W/N\mat{W}\T\mat{W}/N: at independent-entry initialization it is Marchenko-Pastur with γ=M/N\gamma = M/N. Training appears as deviations from that null law, classified into phases: random, eigenvalue ‘bleeding’ outside bulk, bulk plus spikes, bulk decay, heavy tail and rank collapse. Their thesis is that large well-trained networks have tails resembling power law ρ(λ)∼λ−α\rho(\lambda) \sim \lambda^{-\alpha}, an implicit self-regularization, and exponent α\alpha correlates with model quality without test data.

The interactive uses precalculated spectra: a small digit perceptron in three variants at five training times, and four GPT-2 small MLP matrices. Each is fitted to Marchenko-Pastur (scale σ2\sigma^2 via median, robust to spikes), with 99% Tracy-Widom threshold marked, α\alpha estimated using Hill on the top 10%, and above all compared with a null model: the same matrix with shuffled entries, preserving each weight’s marginal law while destroying correlations.

InteractiveReal network weight spectra
Spectral density of W⊤W/N\mat{W}\T\mat{W}/N (epoch 200)
TW threshold
  • trained network
  • null: shuffled entries
  • fitted Marchenko–Pastur
  • eigenvalues above threshold
The 200 largest eigenvalues versus rank (log-log)
  • trained network
  • shuffled null
  • Hill fit, α = 2.25
  • TW threshold
Capa
200
Training / test accuracy100.0 % / 97.6 %
Shape N×M and γ=M/N\gamma = M/N512×256, 0.500
λmax⁡\lambda_{\max} / fitted MP edge11.6 (null: 2)
Eigenvalues above 99% TW threshold10 (null: 1)
Fraction of ∥W∥F2\norm{\mat{W}}_F^2 outside the bulk41.6 %
Hill α\alpha (25 largest)2.25 (null: 6.89)
10 isolated eigenvalues with 10 classes: bulk plus spikes, a low-rank perturbation. Hill’s α\alpha (2.25) measures no tail here: it mixes spikes with the bulk edge, with no power law to fit.
The null also has an isolated eigenvalue: shuffling preserves each weight's distribution, including its mean, and a nonzero mean is a rank-one perturbation μ 11⊤\mu\,\vb{1}\vb{1}\T. It is a BBP spike, not learned structure.
Spectral density of W⊤W/N\mat{W}\T\mat{W}/N on logarithmic scale (left) and largest eigenvalues versus rank on log-log axes (right), where a power law is a line. Step through perceptron epochs: at 0 all is Marchenko-Pastur; training on real labels produces about ten spikes, one per class; shuffled labels produce memorization and dozens. Hill's perceptron α\alpha is small despite no tail: it measures spikes. Then choose GPT-2: about a hundred of 768 eigenvalues outside bulk and a seemingly power-law tail. The shuffled null returns to bulk, except one spike when mean weight is nonzero.

These data are useful precisely because their conclusions are modest:

  • Learning a simple task is low rank. With 10 classes, perceptron matrix W2\mat{W}_2 has 10 eigenvalues above threshold from epoch 3 (9 with He initialization), and the rest remains Marchenko-Pastur at slightly smaller scale. Training is a low-rank perturbation of initialization, the ‘bulk plus spikes’ phase.
  • Memorization costs rank. With shuffled labels the network reaches 100% training accuracy (without generalizing) with about 60 directions outside bulk in the same layer.
  • GPT-2 is different. In the interactive’s four MLP matrices, 83 to 111 of 768 eigenvalues exceed threshold, the largest exceeds ten times the fitted edge, and rank versus eigenvalue is almost straight: a genuine heavy tail. The shuffled null returns nearly perfect Marchenko-Pastur with edge (1+0.25)2=2.25(1 + \sqrt{0.25})^2 = 2.25 (at most one eigenvalue touches threshold), so the tail resides in joint weight structure, not individual weight law.
  • A tail estimator cannot know what it measures. Hill on the top 10% gives α\alpha between 1.7 and 2.5 for the real-label, reduced-initialization perceptron, ‘very heavy tail’ values (smaller than GPT-2’s 3.4 to 4.2), because it mixes ten spikes with the bulk edge. Without the null and the spectrum the number misleads. Power-law fitting with few points is delicate (Clauset, Shalizi and Newman, 2009), and Martin and Mahoney carefully choose the tail start before fitting.

With that caution, this is a serious research program: weight spectra diagnose training without test data (reliability module), Jacobian spectra help choose dynamical-isometry initializations, and Hessian spectra illuminate optimization. Each asks what noise explains and what it does not.

Lab: spectral laws from scratch

Four NumPy experiments using only eigvalsh. First, semicircle universality, with moments versus Catalan numbers.

[ ]Wigner: semicircle, moments and universalityBrowser
import numpy as np
import matplotlib.pyplot as plt

rng = np.random.default_rng(0)

def wigner(n, ley):
    if ley == "gaussiana":
        X = rng.standard_normal((n, n))
    elif ley == "rademacher":
        X = rng.choice([-1.0, 1.0], size=(n, n))
    else:                                            # uniforme en [−√3, √3]: varianza 1
        X = rng.uniform(-np.sqrt(3), np.sqrt(3), size=(n, n))
    X = np.triu(X) + np.triu(X, 1).T                 # simétrica: manda el triángulo superior
    return X / np.sqrt(n)

def semicirculo(x):
    return np.sqrt(np.clip(4 - x ** 2, 0, None)) / (2 * np.pi)

n = 300
xs = np.linspace(-2.3, 2.3, 400)
fig, ax = plt.subplots(figsize=(7, 3.2))
for ley in ["gaussiana", "rademacher", "uniforme"]:
    lam = np.linalg.eigvalsh(wigner(n, ley))
    mom = [np.mean(lam ** (2 * k)) for k in (1, 2, 3, 4)]
    print(f"{ley:10s} λmax = {lam.max():.3f}   momentos pares 2, 4, 6, 8: " + "  ".join(f"{m:6.3f}" for m in mom))
    ax.hist(lam, bins=40, density=True, histtype="step", lw=1.5, label=ley)
print("Catalan:                         " + "  ".join(f"{c:6d}" for c in (1, 2, 5, 14)))
ax.plot(xs, semicirculo(xs), "k", lw=2, label="semicírculo")
ax.legend(fontsize=8); plt.show()

Second, Marchenko-Pastur: hand-derived density, histogram comparison, first two moments and numerical Stieltjes inversion.

[ ]Marchenko-Pastur and its Stieltjes transformBrowser
import numpy as np
import matplotlib.pyplot as plt

rng = np.random.default_rng(1)

def mp_densidad(x, g, s2=1.0):
    lm, lp = s2 * (1 - np.sqrt(g)) ** 2, s2 * (1 + np.sqrt(g)) ** 2
    x = np.asarray(x, dtype=float)
    dentro = (x > lm) & (x < lp)
    out = np.zeros_like(x)
    out[dentro] = np.sqrt((lp - x[dentro]) * (x[dentro] - lm)) / (2 * np.pi * g * s2 * x[dentro])
    return out

def mp_stieltjes(z, g):
    """Raíz de γ z s² + (z − 1 + γ) s + 1 = 0 con Im s > 0 (la transformada de una medida)."""
    a, b = g * z, z - 1 + g
    raiz = np.sqrt(b * b - 4 * a + 0j)
    s1, s2 = (-b + raiz) / (2 * a), (-b - raiz) / (2 * a)
    return np.where(s1.imag > 0, s1, s2)

n, d = 800, 400
g = d / n
X = rng.standard_normal((n, d))
lam = np.linalg.eigvalsh(X.T @ X / n)
print(f"γ = {g}:  autovalores en [{lam.min():.3f}, {lam.max():.3f}];  bordes teóricos "
      f"[{(1 - np.sqrt(g)) ** 2:.3f}, {(1 + np.sqrt(g)) ** 2:.3f}]")
print(f"media {lam.mean():.4f} (teoría 1);  varianza {lam.var():.4f} (teoría (d + 1)/n = {(d + 1) / n:.4f})")

xs = np.linspace(0.01, 3.2, 600)
inversion = mp_stieltjes(xs + 1e-9j, g).imag / np.pi
print("máx |densidad por inversión − fórmula cerrada| =", f"{np.max(np.abs(inversion - mp_densidad(xs, g))):.1e}")

# la transformada empírica, (1/d) tr(Σ̂ − z)^(-1), ya está cerca de la teórica a distancia η = 0.05 del eje
z = xs + 0.05j
emp = np.mean(1 / (lam[None, :] - z[:, None]), axis=1)
print("máx |s_emp − s_MP| a altura 0.05:", f"{np.max(np.abs(emp - mp_stieltjes(z, g))):.3f}")

plt.hist(lam, bins=50, density=True, alpha=0.5, label="autovalores de Σ̂")
plt.plot(xs, mp_densidad(xs, g), "k", label="Marchenko-Pastur")
plt.plot(xs, emp.imag / np.pi, "--", label="Im s_emp(x + 0.05i)/π")
plt.legend(); plt.show()

Inversion reproduces the closed formula with error 10−710^{-7} introduced by height η=10−9\eta = 10^{-9} near edges; the empirical transform at height η=0.05\eta = 0.05 smooths the histogram, as used in practice with finite spectra.

Third, the BBP threshold from scratch, with the same noise for every β\beta as in the figure.

[ ]The BBP thresholdBrowser
import numpy as np

rng = np.random.default_rng(3)
n, d = 600, 300
g = d / n
Z = rng.standard_normal((n, d))
S0 = Z.T @ Z / n
print(f"γ = {g},  umbral √γ = {np.sqrt(g):.3f},  borde (1 + √γ)² = {(1 + np.sqrt(g)) ** 2:.3f}\n")
print("   β    λ1 simulado   λ1 límite   solapamiento   límite")
for beta in [0.2, 0.4, 0.6, 0.7, 0.8, 1.0, 1.5, 2.0, 3.0]:
    c = np.sqrt(1 + beta)                     # x = Z Σ^(1/2) con Σ = I + β e1 e1ᵀ: reescalar la coordenada 1
    S = S0.copy(); S[0, :] *= c; S[:, 0] *= c
    w, V = np.linalg.eigh(S)
    arriba = beta > np.sqrt(g)
    lam_lim = (1 + beta) * (1 + g / beta) if arriba else (1 + np.sqrt(g)) ** 2
    ov_lim = (1 - g / beta ** 2) / (1 + g / beta) if arriba else 0.0
    print(f"{beta:5.2f}   {w[-1]:9.3f}   {lam_lim:9.3f}    {V[0, -1] ** 2:9.3f}   {ov_lim:9.3f}")

Fourth, matrix Bernstein versus reality. Both laws have exactly Σ=I\mat{\Sigma} = \mat{I} and ∥x∥2=d\norm{\vb{x}}^2 = d, so the bound is identical; true error differs. To see factor log⁡d\log d vary dd, fixing γ=d/n=1/16\gamma = d/n = 1/16 and increasing dimension.

[ ]Matrix Bernstein versus true covariance errorBrowser
import numpy as np

rng = np.random.default_rng(4)
gam = 1 / 16                                 # n = 16 d en todas las filas

def error_esfera(n, d):                      # x uniforme en la esfera de radio √d
    G = rng.standard_normal((n, d))
    X = np.sqrt(d) * G / np.linalg.norm(G, axis=1, keepdims=True)
    return np.max(np.abs(np.linalg.eigvalsh(X.T @ X / n - np.eye(d))))

def error_coordenadas(n, d):                 # x = √d e_J: Σ̂ es diagonal con entradas d·N_j/n
    cuentas = np.bincount(rng.integers(0, d, size=n), minlength=d)
    return np.max(np.abs(d * cuentas / n - 1))

print("     d       n   cota de Bernstein   esfera   2√γ + γ   coordenadas")
for d in [8, 32, 128, 512, 2048]:
    n = int(d / gam)
    L = v = d / n                            # m = d y ‖Σ‖ = 1
    cota = np.sqrt(2 * v * np.log(2 * d)) + L * np.log(2 * d) / 3
    e_esf = np.mean([error_esfera(n, d) for _ in range(4)]) if d <= 128 else float("nan")
    e_coo = np.mean([error_coordenadas(n, d) for _ in range(20)])
    print(f"{d:6d}  {n:6d}   {cota:12.3f}     {e_esf:7.3f}   {2 * np.sqrt(gam) + gam:7.3f}   {e_coo:9.3f}")

The bound holds for both laws and grows with dd due to log⁡2d\sqrt{\log 2d}. Sphere error does not grow with it: it stabilizes at extreme-singular-value prediction 2γ+γ=0.56252\sqrt\gamma + \gamma = 0.5625, approaching from below (0.430.43, 0.520.52, 0.550.55). Coordinate-sampling error does grow with dd at the bound’s rate: it is the maximum of dd binomial fluctuations, and for the maximum of dd variables log⁡d\sqrt{\log d} is inevitable. Matrix Bernstein is optimal for its class’s worst case, not every distribution.

Library version: GPT-2 spectra

For pretrained models use transformers to load weights and standard linear algebra for the rest. GPT-2 small stores linear layers as Conv1D with shape (input, output): MLP layers are 768×3072768\times 3072 and 3072×7683072\times 768. The cell analyzes all 24 MLP matrices with the interactive’s protocol. CPU runtime is under a minute, mostly importing transformers and loading the model (eigenvalues of 48 768×768768\times 768 matrices take seconds); the first run downloads about 500 MB of weights.

[ ]Spectra of GPT-2’s 24 MLP matricesLocal GPU
import numpy as np
import torch
from transformers import GPT2LMHeadModel

torch.set_num_threads(4)
modelo = GPT2LMHeadModel.from_pretrained("gpt2")
pesos = {k: v.detach().double().numpy() for k, v in modelo.state_dict().items()
         if k.endswith(("mlp.c_fc.weight", "mlp.c_proj.weight"))}
del modelo

def mediana_mp(g, K=20000):
    lm, lp = (1 - np.sqrt(g)) ** 2, (1 + np.sqrt(g)) ** 2
    x = np.linspace(lm, lp, K)
    dens = np.sqrt(np.clip((lp - x) * (x - lm), 0, None)) / (2 * np.pi * g * x)
    cdf = np.cumsum(dens); cdf /= cdf[-1]
    return x[np.searchsorted(cdf, 0.5)]

def analiza(W):
    A = W if W.shape[0] >= W.shape[1] else W.T              # N × M con N ≥ M
    N, M = A.shape
    g = M / N
    lam = np.sort(np.linalg.eigvalsh(A.T @ A / N))[::-1]
    s2 = np.median(lam) / mediana_mp(g)                     # escala del bulk, robusta a espigas
    a = np.sqrt(N - 1) + np.sqrt(M)
    umbral = s2 * (a * a / N + 2.02 * a * (1 / np.sqrt(N - 1) + 1 / np.sqrt(M)) ** (1 / 3) / N)
    k = int(0.1 * M)
    hill = 1 + k / np.sum(np.log(lam[:k] / lam[k]))
    return (lam > umbral).sum(), lam[0] / (s2 * (1 + np.sqrt(g)) ** 2), hill

rng = np.random.default_rng(0)
print("matriz            fuera   λmax/borde   α Hill  |  nulo: fuera   α Hill")
for nombre, W in pesos.items():
    fuera, ratio, hill = analiza(W)
    fuera0, _, hill0 = analiza(rng.permutation(W.ravel()).reshape(W.shape))
    corto = nombre.removeprefix("transformer.").removesuffix(".weight")   # p. ej. h.0.mlp.c_fc (bloques desde 0)
    print(f"{corto:16s} {fuera:5d}   {ratio:9.1f}   {hill:6.2f}  |  {fuera0:9d}   {hill0:6.2f}")
This cell needs the local lab (PyTorch with your GPU). Start it with npm run lab and open the connection link.

Read output as in the interactive: out-of-bulk eigenvalue count and tail exponent are descriptions meaningful against the null. All c_fc and almost all c_proj have 80 to 112 outliers (fewer in h.0, h.1 and h.11.mlp.c_proj, with 48, 41 and 72); largest is 8 to 39 times the edge, and most nulls have none or almost none. But in early-block c_proj the shuffled null retains up to 17 above threshold and α\alpha falls from 10 to 6.5. These matrices have a few enormous individual weights (in h.1.mlp.c_proj to h.3.mlp.c_proj, over 150 standard deviations from the mean, with kurtosis of hundreds): a heavy-tailed marginal law explaining part of the spectral tail without weight correlations. Separating both sources is exactly the null model’s purpose. Martin’s weightwatcher library automates analysis with more careful power-law fitting (Kolmogorov-Smirnov tail-start selection, as in Clauset et al.); useful, but do the transparent version first.

Common mistakes

Exercises

NumericMarchenko-Pastur upper edge
Data with Σ=I\mat{\Sigma} = \mat{I}, n=4000n = 4000 observations and d=1000d = 1000 variables. According to Marchenko-Pastur, near what value is the largest sample-covariance eigenvalue?
NumericThe sixth moment
For a normalized Wigner matrix, to what value does 1nEtr⁡W6\frac1n\E\tr\mat{W}^6 converge?
QuizWhen does the spike separate?
In spiked model Σ=I+βuu⊤\mat{\Sigma} = \mat{I} + \beta\vb{u}\vb{u}\T with γ=d/n=0.5\gamma = d/n = 0.5, above what strength β\beta does the largest sample-covariance eigenvalue separate (in the limit) from Marchenko-Pastur bulk?
NumericHow much PCA sees
Spiked model with γ=0.25\gamma = 0.25 and β=1\beta = 1. To what does ⟨v^1,u⟩2\langle\hat{\vb{v}}_1, \vb{u}\rangle^2, squared cosine between first principal component and true direction, converge?
NumericNear the interpolation threshold
Least squares with isotropic Gaussian rows, noise variance σ2=1\sigma^2 = 1 and d/n→γ=0.9d/n \to \gamma = 0.9. To what does E∥β^−β∥2\E\norm{\hat{\vb{\beta}} - \vb{\beta}}^2 tend?
QuizTwo fluctuation scales
Data with n=104n = 10^4 and d=5⋅103d = 5\cdot 10^3. Compare the largest eigenvalue of Σ^\hat{\mat{\Sigma}} in (A) pure noise, Σ=I\mat{\Sigma} = \mat{I}; (B) spike β=2\beta = 2, well above threshold. Which statement correctly describes fluctuations around their limits?
QuizReading a weight spectrum
A trained 512×256512\times 256 layer has 10 eigenvalues far above the Marchenko-Pastur edge, and Hill on the largest 25 gives α≈2\alpha \approx 2. After shuffling entries, the spectrum returns to Marchenko-Pastur except one outlier. What conclusion is correct?
ProofThe fourth moment via Dyck paths
Prove: For Wigner matrix W=X/n\mat{W} = \mat{X}/\sqrt n with mean-0, variance-1 entries and finite moments, 1nEtr⁡W4→2=C2\frac1n\E\tr\mat{W}^4 \to 2 = C_2, the semicircle's fourth moment.
0
Write 1nEtr⁡W4=n−3∑i1,i2,i3,i4E[Xi1i2Xi2i3Xi3i4Xi4i1]\frac1n\E\tr\mat{W}^4 = n^{-3}\sum_{i_1, i_2, i_3, i_4}\E[X_{i_1i_2}X_{i_2i_3}X_{i_3i_4}X_{i_4i_1}]: a sum over closed 4-step walks.

Step 1 of 4. Which walks can contribute a nonzero term?

ProofMatrix Bernstein for covariance
Prove: If x1,…,xn\vb{x}_1, \dots, \vb{x}_n are independent copies of a centered vector x∈Rd\vb{x} \in \R^d with Exx⊤=Σ\E\vb{x}\vb{x}\T = \mat{\Sigma} and ∥x∥2≤m\norm{\vb{x}}^2 \le m almost surely, then E∥Σ^−Σ∥≤2m∥Σ∥log⁡(2d)/n+mlog⁡(2d)/(3n)\E\norm{\hat{\mat{\Sigma}} - \mat{\Sigma}} \le \sqrt{2m\norm{\mat{\Sigma}}\log(2d)/n} + m\log(2d)/(3n).
0
Use matrix Bernstein in expectation: E∥∑kXk∥≤2vlog⁡(2d)+13Llog⁡(2d)\E\norm{\sum_k\mat{X}_k} \le \sqrt{2v\log(2d)} + \tfrac13L\log(2d), with ∥Xk∥≤L\norm{\mat{X}_k} \le L and v=∥∑kEXk2∥v = \norm{\sum_k\E\mat{X}_k^2}.

Step 1 of 4. How do you write Σ^−Σ\hat{\mat{\Sigma}} - \mat{\Sigma} as a sum of independent centered matrices?

CodeMarchenko-Pastur density and moment fitting
Implement mp_density(x, gamma, sigma2), the Marchenko-Pastur density with ratio γ∈(0,1]\gamma \in (0, 1] and variance σ2\sigma^2 (zero outside support; x may be an array), and fit_mp(eigs), estimating (gamma, sigma2) from observed sample-covariance eigenvalues by moments. Use mean σ2\sigma^2 and second moment σ4(1+γ)\sigma^4(1 + \gamma).
import numpy as np

def mp_density(x, gamma, sigma2=1.0):
  """Densidad de Marchenko-Pastur (parte continua) en los puntos x."""
  x = np.asarray(x, dtype=float)
  return np.zeros_like(x)

def fit_mp(eigs):
  """Estima (gamma, sigma2) por momentos a partir de los autovalores."""
  eigs = np.asarray(eigs, dtype=float)
  return 0.0, 0.0
Shift+Enter to run

Summary

Key idea
When dimension grows with data, a random matrix’s spectrum differs from that of its mean: noise spreads into a deterministic law (semicircle, Marchenko-Pastur) with edges σ2(1±d/n)2\sigma^2(1 \pm \sqrt{d/n})^2, and signal is visible only if it leaves that bulk, requiring an exact threshold.
  • Matrix Bernstein bounds independent matrix sums using matrix variance v=∥∑EXk2∥v = \norm{\sum\E\mat{X}_k^2} and dimension factor log⁡d\log d; for covariance it gives n≳rlog⁡d/ε2n \gtrsim r\log d/\eps^2 samples with effective rank rr.
  • For Gaussian matrices n×dn\times d, n−d≲smin⁡≤smax⁡≲n+d\sqrt n - \sqrt d \lesssim s_{\min} \le s_{\max} \lesssim \sqrt n + \sqrt d with Gaussian tails: covariance error is ≈2d/n\approx 2\sqrt{d/n} without a logarithm. ε-nets give the order; Gordon gives the constant.
  • Semicircle: by the moment method, Wigner even moments approach Catalan numbers because only tree walks (Dyck paths) survive. The limit depends only on entry variance.
  • Marchenko-Pastur: isotropic-noise sample covariance has eigenvalue variance ≈γ\approx\gamma around 1, edges (1±γ)2(1 \pm \sqrt\gamma)^2; inverse moment 1/(1−γ)1/(1 - \gamma) explains the double-descent peak.
  • BBP: spike β\beta is PCA-visible iff β>d/n\beta > \sqrt{d/n}; then the eigenvalue is biased, (1+β)(1+γ/β)(1 + \beta)(1 + \gamma/\beta), and overlap is (1−γ/β2)/(1+γ/β)<1(1 - \gamma/\beta^2)/(1 + \gamma/\beta) < 1.
  • At finite size the edge fluctuates as n−2/3n^{-2/3} (Tracy-Widom), an isolated eigenvalue as n−1/2n^{-1/2}. Network weight spectra require a null: the perceptron learns low rank; GPT-2 has a genuine heavy tail.