Module contents
Lesson 11 of 24Advanced 110 min

High-dimensional and robust PCA: noise, rank and outliers

High-dimensional PCA, noise spectra, signal detection, covariance estimation and robust PCA.

After this lesson you can

  • Explain the Marchenko-Pastur spectrum and BBP transition.
  • Select components using parallel analysis and singular-value thresholds.
  • Assess covariance estimation and robustness in high dimensions.
  • Implement techniques for identifying and recovering low-rank signals.

Before you start

Motivation: 500 assets and two years of data

You have daily returns for d=500d = 500 stocks over two years, around n=504n = 504 trading days. You want to know how many common factors move the market (the overall market, sectors, size…), which stocks each loads on, and then build a minimum-risk portfolio using estimated covariance. The previous lesson’s PCA recipe seems direct: compute Σ^=1nX⊤X\hat{\mat{\Sigma}} = \frac1n\mat{X}\T\mat{X} from centered data, diagonalize it, inspect the scree plot and retain components before the elbow.

With dd comparable to nn, that recipe misleads in four ways. No market is needed to see it: pure noise suffices, independent returns with variance 1 whose true covariance is identity and has no factor.

[ ]Pure noise with 500 assets and 504 daysBrowser
import numpy as np

rng = np.random.default_rng(0)
n, d = 504, 500
X = rng.standard_normal((n, d))
Xc = X - X.mean(axis=0)
lam = np.linalg.eigvalsh(Xc.T @ Xc / n)[::-1]
g = d / n
lo, hi = (1 - np.sqrt(g)) ** 2, (1 + np.sqrt(g)) ** 2
print(f"gamma = d/n = {g:.3f}; bulk de Marchenko-Pastur: [{lo:.1e}, {hi:.3f}]")
print("cinco mayores:", np.round(lam[:5], 3), "(los verdaderos valen 1)")
print(f"menor: {lam[-1]:.1e}")
print(f"varianza 'explicada' por las 10 primeras: {lam[:10].sum() / lam.sum():.3f} (le tocaría {10 / d:.3f})")
  1. The spectrum widens. All true eigenvalues equal 1, while sample values range from almost 0 to 3.9. The first ten “components” explain 7.4% of variance when their share should be 2%, and the scree plot falls smoothly as with real data. Without a noise reference, there is no way to tell if an eigenvalue of 3.9 is signal.
  2. Directions are also noise. If a weak component emerges above noise, its eigenvector can be closer to a random direction than the true one. Interpreting its loadings (“this factor is banking”) is reading tea leaves.
  3. Covariance cannot be inverted reliably. The smallest eigenvalue is of order 10−610^{-6} when the true value is 1. A minimum-variance portfolio uses Σ^−1\hat{\mat{\Sigma}}\inv, amplifying precisely those falsely safe directions: perceived and actual risk can differ by an order of magnitude.
  4. One bad observation changes everything. A day with a wrongly recorded price multiplied by 100 can take over the first component. Classical PCA minimizes squared error and has no protection against this.

This lesson addresses all four. Its tools are two random-matrix results proved in the probability module, the Marchenko-Pastur law and BBP transition, and one convex optimization idea: separating a matrix into low-rank and sparse parts using the nuclear norm and ℓ1\ell_1 norm.

Recap: the d/n→γd/n \to \gamma regime on one page

Let independent x1,…,xn∈Rd\vb{x}_1, \dots, \vb{x}_n \in \R^d have mean 0 and covariance Σ\mat{\Sigma}, with Σ^=1n∑ixixi⊤\hat{\mat{\Sigma}} = \frac1n\sum_i\vb{x}_i\vb{x}_i\T. The entire lesson lives in the proportional regime: n,d→∞n, d \to \infty with

γ=dn∈(0,∞)fixed.\gamma = \frac{d}{n} \in (0, \infty) \quad \text{fixed}.

Mind the order: γ\gamma is variables divided by observations. Financial literature often writes q=N/Tq = N/T, the same ratio, while some texts use its inverse. Small γ\gamma gives the classical world (Σ^→Σ\hat{\mat{\Sigma}} \to \mat{\Sigma}); order-1 γ\gamma does not.

Pure noise. If Σ=σ2I\mat{\Sigma} = \sigma^2\mat{I} (independent entries, variance σ2\sigma^2, finite fourth moment), the Marchenko-Pastur law says the eigenvalue histogram of Σ^\hat{\mat{\Sigma}} converges to a deterministic density supported on

[λ−,λ+]=[σ2(1−γ)2,  σ2(1+γ)2],[\lambda_-, \lambda_+] = \Big[\sigma^2\big(1 - \sqrt\gamma\big)^2,\; \sigma^2\big(1 + \sqrt\gamma\big)^2\Big],

plus an atom at 0 of mass 1−1/γ1 - 1/\gamma if γ>1\gamma > 1. This interval is the bulk. The largest eigenvalue converges to edge λ+\lambda_+ with fluctuations of order n−2/3n^{-2/3} following the Tracy-Widom law (Johnstone, 2001). With γ=0.992\gamma = 0.992 the bulk is [1.6⋅10−5, 3.98][1.6\cdot 10^{-5},\, 3.98]: exactly what you saw.

One signal. If Σ=σ2(I+βuu⊤)\mat{\Sigma} = \sigma^2(\mat{I} + \beta\vb{u}\vb{u}\T) with ∥u∥=1\norm{\vb{u}} = 1 (Johnstone’s spiked model), the BBP transition says that with σ2=1\sigma^2 = 1 and γ≤1\gamma \le 1:

λ^1→{(1+γ)2if β≤γ,(1+β)(1+γβ)if β>γ,⟨v^1,u⟩2→{0if β≤γ,1−γ/β21+γ/βif β>γ.\hat\lambda_1 \to \begin{cases} (1 + \sqrt\gamma)^2 & \text{if } \beta \le \sqrt\gamma, \\[2pt] (1 + \beta)\Big(1 + \dfrac{\gamma}{\beta}\Big) & \text{if } \beta > \sqrt\gamma, \end{cases} \qquad \inner{\hat{\vb{v}}_1}{\vb{u}}^2 \to \begin{cases} 0 & \text{if } \beta \le \sqrt\gamma, \\[2pt] \dfrac{1 - \gamma/\beta^2}{1 + \gamma/\beta} & \text{if } \beta > \sqrt\gamma. \end{cases}

Below threshold γ\sqrt\gamma the signal is invisible to the spectrum: neither eigenvalue nor eigenvector reveals it. Above it, the eigenvalue separates from the bulk but is upward biased (with β=1\beta = 1 and γ=0.5\gamma = 0.5, the limit is 3.0, not 2), and the eigenvector only partially aligns. With several well-separated spikes, the result applies to each separately.

The same story in singular values. For recovering a matrix rather than covariance use the additive model Y=X+σZ\mat{Y} = \mat{X} + \sigma\mat{Z}, with Z∈Rn×n\mat{Z} \in \R^{n\times n} having standard normal entries and fixed-rank X=∑kxkn σ akbk⊤\mat{X} = \sum_k x_k\sqrt{n}\,\sigma\,\vb{a}_k\vb{b}_k\T. In units of n σ\sqrt n\,\sigma, noise singular values fill [0,2][0, 2] (for a rectangular m×nm \times n matrix with m≤nm \le n, the interval [1−m/n, 1+m/n][1 - \sqrt{m/n},\, 1 + \sqrt{m/n}]). Benaych-Georges and Nadakuditi (2012) calculated the BBP analogue: if xk>1x_k > 1,

ykn σ→xk+1xk,⟨u^k,ak⟩2→1−1xk2,⟨v^k,bk⟩2→1−1xk2,\frac{y_k}{\sqrt n\,\sigma} \to x_k + \frac{1}{x_k}, \qquad \inner{\hat{\vb{u}}_k}{\vb{a}_k}^2 \to 1 - \frac{1}{x_k^2}, \qquad \inner{\hat{\vb{v}}_k}{\vb{b}_k}^2 \to 1 - \frac{1}{x_k^2},

and if xk≤1x_k \le 1 the singular value sticks to edge 2 and overlaps tend to 0. We use this to derive the Gavish-Donoho threshold.

How many components are signal?

The scree plot mixes two things: what is present and what sampling manufactures. The first figure below, with factors set to zero, is pure fabrication, yet its shape invites searching for an elbow. To separate them we need a reference: what spectrum would these same data produce with no common structure? There are two ways to obtain it.

The Marchenko-Pastur edge. If noise is homoscedastic with variance σ2\sigma^2, retain eigenvalues above σ2(1+γ)2\sigma^2(1 + \sqrt\gamma)^2. Estimating σ2\sigma^2 from mean eigenvalue fails because strong factors bias it. Robustly match medians instead. Since almost all eigenvalues are noise, the sample median of λ^1,…,λ^d\hat\lambda_1, \dots, \hat\lambda_d barely notices signal, and σ^2=med⁡(λ^)/mγ\hat\sigma^2 = \operatorname{med}(\hat\lambda)/m_\gamma, with mγm_\gamma the Marchenko-Pastur median at σ2=1\sigma^2 = 1, is consistent. Add a margin of a few Tracy-Widom scales to the edge, because in a finite sample the largest noise eigenvalue fluctuates around λ+\lambda_+ at scale n−2/3n^{-2/3} and exceeds it with appreciable probability.

Horn’s parallel analysis. Horn (1965) proposed generating random data of the same size n×dn \times d, computing eigenvalues and retaining components whose eigenvalue exceeds that of simulated data at the same index. Buja and Eyuboglu (1992) replaced simulated data with permutations: independently shuffle each column of X\mat{X}, destroying dependence between variables while exactly preserving each marginal distribution. Repeat BB times and use the mean (Horn) or a high quantile (Glorfeld, 1995, proposed 95%) of the kk-th permuted eigenvalues as the index-kk reference.

Each reference embodies a different null hypothesis. The edge assumes isotropic noise with one variance. Parallel analysis assumes independent columns of noise with arbitrary marginals: it adapts to different variances and heavy tails because permutation preserves each column exactly. But it has two weaknesses the figure reveals:

  • Shadow of strong factors. A factor loading on every variable contributes variance to each column, preserved by permutation: permuted columns have variance 1+β1uj21 + \beta_1u_j^2 instead of 1, raising their spectrum. Dobriban (2020) showed parallel analysis consistently selects large factors in certain high-dimensional models but not small ones; the figure shows it can miss a factor visible in the spectrum. In finance, where the market factor is huge, this matters.
  • Dependent noise. If noise is correlated across variables (neighboring sensors, assets from one country) or over time (autocorrelated series), the permuted reference does not reproduce it and parallel analysis counts that dependence as factors.
InteractiveSignal or bulk?
The 12 largest eigenvalues of Σ^\hat{\mat{\Sigma}} (log scale)
borde MP (1 + √γ)² = 2.91
  • data eigenvalues (blue: retained by parallel analysis)
  • permuted data: mean (dashed) and maximum over 10
  • Marchenko–Pastur edge
  • BBP limit of each detectable factor (hollow circle, orange for the weak factor)
400
200
6
0.60
Noise
γ=d/n\gamma = d/n and threshold γ\sqrt{\gamma}0.50 and 0.71
Factors with βk>γ\beta_k > \sqrt\gamma2 of 3
Parallel analysis (maximum)2
Parallel analysis (mean, Horn)3
MP edge with σ2=1\sigma^2 = 12 (edge 2.91)
The third factor exists (β3=0.60\beta_3 = 0.60) but lies below the BBP threshold γ=0.71\sqrt{\gamma} = 0.71. Its eigenvalue stays inside the bulk and is undetectable by these spectral criteria. Horn’s mean rule counts 3. It compares residual noise after the factors with higher-index permuted eigenvalues and overestimates the count.
Data with three factors, xi=∑kβkfikuk+zi\vb{x}_i = \sum_k\sqrt{\beta_k}f_{ik}\vb{u}_k + \vb{z}_i with fixed β2=2\beta_2 = 2. Points are the 12 largest eigenvalues of Σ^\hat{\mat{\Sigma}} on a logarithmic scale; the gray band spans mean to maximum of 10 permutations (parallel analysis), the red line is the Marchenko-Pastur edge with σ2=1\sigma^2 = 1, and hollow circles are the BBP limit of each detectable factor. Initially the third factor exists, β3=0.6\beta_3 = 0.6, but lies below γ=0.71\sqrt{\gamma} = 0.71: no criterion can see it. Raise it until it emerges, then raise the dominant factor to 60 and watch the gray band swallow the second factor, and finally switch to heteroscedastic noise.

Three things the figure shows and the lab quantifies:

  1. Undetectable cannot be rescued with a better criterion. Below γ\sqrt\gamma, the information is absent from the spectrum. The only way out is changing γ\gamma: more observations or fewer variables (for example by aggregation).
  2. The elbow misleads both ways. With pure noise it suggests nonexistent components; with a huge dominant factor, the jump after λ^1\hat\lambda_1 hides smaller real factors that do exceed the bulk.
  3. A single-σ2\sigma^2 Marchenko-Pastur edge is fragile. With heteroscedastic noise it counts high-variance noise directions as factors, while parallel analysis adapts.

The optimal Gavish-Donoho hard threshold

Counting factors differs from deciding how many components to use to reconstruct a matrix. Suppose you observe Y=X+σZ\mat{Y} = \mat{X} + \sigma\mat{Z} (an image, ratings matrix or measurement table) and want to estimate X\mat{X} by truncated SVD: retain singular values yky_k above threshold τ\tau and zero the rest,

X^τ=∑k: yk>τyk u^kv^k⊤.\hat{\mat{X}}_\tau = \sum_{k:\, y_k > \tau} y_k\,\hat{\vb{u}}_k\hat{\vb{v}}_k\T .

This is PCA’s low-rank reconstruction, with data-selected rank. Gavish and Donoho (2014) ask which τ\tau minimizes squared error ∥X^τ−X∥F2\norm{\hat{\mat{X}}_\tau - \mat{X}}_F^2. The natural answer, “the bulk edge, so no noise passes,” is incorrect.

Proof

Work in units of n σ\sqrt n\,\sigma. Since 4/3>24/\sqrt3 > 2, no bulk singular value exceeds the threshold, so decide only for each component with xk>1x_k > 1 whether to retain it. Cross terms between distinct components vanish in the limit (their singular vectors are asymptotically orthogonal), and component kk contributes to normalized error ∥X^−X∥F2/(nσ2)\norm{\hat{\mat{X}} - \mat{X}}_F^2/(n\sigma^2): x2x^2 if discarded and, if retained (with signs of u^,v^\hat{\vb{u}}, \hat{\vb{v}} aligned with a,b\vb{a}, \vb{b}),

∥x ab⊤−y u^v^⊤∥F2=x2+y2−2xy ⟨u^,a⟩⟨v^,b⟩→x2+y2−2xy(1−1x2),\norm{x\,\vb{a}\vb{b}\T - y\,\hat{\vb{u}}\hat{\vb{v}}\T}_F^2 = x^2 + y^2 - 2xy\,\inner{\hat{\vb{u}}}{\vb{a}}\inner{\hat{\vb{v}}}{\vb{b}} \to x^2 + y^2 - 2xy\Big(1 - \frac{1}{x^2}\Big),

with y=x+1/xy = x + 1/x by Benaych-Georges and Nadakuditi. Retaining is better if and only if y2<2xy(1−1/x2)y^2 < 2xy(1 - 1/x^2), that is y<2x−2/xy < 2x - 2/x. Substitute yy: x+1/x<2x−2/x  ⟺  3/x<x  ⟺  x>3x + 1/x < 2x - 2/x \iff 3/x < x \iff x > \sqrt3. Since y=x+1/xy = x + 1/x increases for x>1x > 1, the signal condition equals an observed condition: y>3+1/3=4/3y > \sqrt3 + 1/\sqrt3 = 4/\sqrt3. Any other threshold retains some component with x<3x < \sqrt3 or discards one with x>3x > \sqrt3, increasing error either way.

∎

The difference from the edge is the difference between seeing a signal and using it. A component with 1<x<31 < x < \sqrt3 emerges above the bulk, but its singular vector is so misaligned (cos⁡2<2/3\cos^2 < 2/3) that adding it introduces more error than it removes. The winner lies above the edge: 4/3≈2.3094/\sqrt3 \approx 2.309 versus 2.

The general result (Gavish and Donoho, 2014) covers m×nm \times n matrices with β=m/n≤1\beta = m/n \le 1: the threshold is λ∗(β)n σ\lambda^*(\beta)\sqrt n\,\sigma with

λ∗(β)=2(β+1)+8β(β+1)+β2+14β+1,\lambda^*(\beta) = \sqrt{2(\beta + 1) + \frac{8\beta}{(\beta + 1) + \sqrt{\beta^2 + 14\beta + 1}}},

which equals 4/34/\sqrt3 at β=1\beta = 1. If σ\sigma is unknown, estimate it from the median observed singular value ymedy_{\mathrm{med}} (the same median matching as before), yielding 2.858 ymed2.858\,y_{\mathrm{med}} for square matrices. The authors quantify gains for a rank-rr matrix n×nn\times n: asymptotic squared error of the optimal threshold is at most 3nrσ23nr\sigma^2, versus 5nrσ25nr\sigma^2 for SVD truncated to true rank, 6nrσ26nr\sigma^2 for best-tuned soft thresholding and 2nrσ22nr\sigma^2 for optimal singular-value shrinkage. That optimal thresholding beats truncation at the true rank is surprising: knowing rr does not help if the last components are weak.

InteractiveA hard threshold for singular values
Singular values yi=si/(n σ)y_i = s_i/(\sqrt n\,\sigma) of Y\mat{Y}
τ = 2.00
Relative error ∥X^τ−X∥F2/∥X∥F2\norm{\hat{\mat{X}}_\tau - \mat{X}}_F^2/\norm{\mat{X}}_F^2 as a function of τ\tau
minimum 0.428
  • your threshold τ\tau
  • Gavish-Donoho (4/3) σ^/σ(4/\sqrt3)\,\hat\sigma/\sigma
  • bulk edge 2 σ^/σ2\,\hat\sigma/\sigma
  • retained singular values
2.00
1.00
Your threshold: components4
Your threshold: relative error0.473
Gavish-Donoho0.428 (3 comp.)
Bulk edge0.473 (4 comp.)
Minimum possible0.428 (3 comp.)
Truncate to true rank0.656 (6 comp.)
Threshold with unknown σ\sigma: 2.858 ymed2.858\,y_{\mathrm{med}}2.427
You retain 4 components and the error is 0.473. The extra component reaches the bulk edge or just beyond it, but add more noise than signal. The minimum is 0.428 at 3 components.
A 100×100100\times100 rank-6 matrix with signals x=(4,2.5,1.9,1.5,1.2,0.7)x = (4, 2.5, 1.9, 1.5, 1.2, 0.7) in units of n σ\sqrt n\,\sigma, plus Gaussian noise. Left: observed singular-value histogram, bulk in [0,2][0, 2] and a few outliers. Drag to move threshold τ\tau (magenta) and inspect relative reconstruction error on the right, a step function of τ\tau. Initially τ\tau is at the bulk edge: it retains components that worsen error. Find the minimum and compare with the dotted Gavish-Donoho line; then move σ^/σ\hat\sigma/\sigma to see the effect of under- or overestimating noise.
[ ]Spike formulas at finite sizeBrowser
import numpy as np

rng = np.random.default_rng(3)
n = 400
xs = np.array([3.0, 2.0, 1.6, 1.3])            # señales en unidades de sqrt(n) sigma
A = np.linalg.qr(rng.standard_normal((n, 4)))[0]
B = np.linalg.qr(rng.standard_normal((n, 4)))[0]
X = (A * xs * np.sqrt(n)) @ B.T
Y = X + rng.standard_normal((n, n))           # sigma = 1
U, s, Vt = np.linalg.svd(Y)
y = s[:4] / np.sqrt(n)
cu = np.abs(np.sum(U[:, :4] * A, axis=0))
cv = np.abs(np.sum(Vt[:4].T * B, axis=0))
print(" x    y medido  x + 1/x   cos² (u, v)    1 - 1/x²   conservar - descartar (medido / límite)")
for k, x in enumerate(xs):
    gain = y[k] ** 2 - 2 * x * y[k] * cu[k] * cv[k]
    lim = (x + 1 / x) * (3 / x - x)
    print(f"{x:.1f}   {y[k]:.3f}    {x + 1 / x:.3f}    {cu[k] ** 2:.3f}, {cv[k] ** 2:.3f}   {1 - 1 / x ** 2:.3f}     {gain:+.3f} / {lim:+.3f}")
print(f"borde 2;  umbral 4/sqrt(3) = {4 / np.sqrt(3):.4f};  señal mínima útil sqrt(3) = {np.sqrt(3):.4f}")

With n=400n = 400 asymptotic formulas already agree to the second digit. The two signals above 3\sqrt3 reduce error when retained (−6.67-6.67 and −1.19-1.19 in units of nσ2n\sigma^2); the two below add error (+0.69+0.69 and +1.91+1.91), even though their observed singular values, 2.28 and 2.06, exceed edge 2.

Eigenvectors near the threshold: loadings you cannot interpret

The limiting overlap ⟨v^1,u⟩2=(1−γ/β2)/(1+γ/β)\inner{\hat{\vb{v}}_1}{\vb{u}}^2 = (1 - \gamma/\beta^2)/(1 + \gamma/\beta) has a more serious practical consequence than eigenvalue bias. Write the estimated eigenvector as

v^1=c u+1−c2 w,w⊥u, ∥w∥=1.\hat{\vb{v}}_1 = c\,\vb{u} + \sqrt{1 - c^2}\,\vb{w}, \qquad \vb{w} \perp \vb{u},\ \norm{\vb{w}} = 1 .

In the isotropic noise model, w\vb{w} is asymptotically a uniform direction in the orthogonal complement of u\vb{u}, so each coordinate is order 1/d1/\sqrt d. If the factor loads on a sector of ss variables with uj=1/su_j = 1/\sqrt s, an estimated sector loading is c/sc/\sqrt s plus error with standard deviation (1−c2)/d\sqrt{(1 - c^2)/d}, while an outside variable has only error. With d=200d = 200, s=20s = 20 and β=1\beta = 1, γ=0.5\gamma = 0.5, the limit is c2=1/3c^2 = 1/3: signal per variable is 0.130.13 and noise 0.0580.058. Even in the sector, an individual loading has signal-to-noise ratio just above 2, and several of the 180 outside variables will have loadings as large as sector variables by chance.

InteractiveLoadings of a weak factor
First eigenvector loadings v^1\hat{\vb{v}}_1 across the 200 variables
carga verdadera 1/√20
  • sector variables (nonzero u\vb{u})
  • other variables (true loading 0)
  • true loading uj=1/20u_j = 1/\sqrt{20}
1.00
Observations nn (with d=200d = 200)
BBP threshold γ\sqrt{\gamma}0.707
λ^1\hat\lambda_1 (MP edge, BBP limit)2.95 (2.91, 3.00)
Measured ⟨v^1,u⟩2\langle\hat{\vb{v}}_1, \vb{u}\rangle^20.258
BBP limit of ⟨v^1,u⟩2\langle\hat{\vb{v}}_1, \vb{u}\rangle^20.333
Sector variables among the 20 largest loadings11 of 20
Just above threshold. ⟨v^1,u⟩2=0.26\langle\hat{\vb{v}}_1, \vb{u}\rangle^2 = 0.26 (limit 0.33). The sector is visible, but the error of an individual loading is on the order of its value.
A factor of strength β\beta loads equally on a sector of 20 of 200 variables (orange). Bars are loadings of the first sample eigenvector v^1\hat{\vb{v}}_1; the dashed line is true loading 1/201/\sqrt{20}. Initially (β=1\beta = 1, γ=0.5\gamma = 0.5) the factor exceeds threshold 0.5=0.71\sqrt{0.5} = 0.71, but limiting overlap is only 1/31/3 and measured overlap at this size is lower: the sector is barely visible among gray bars as high as orange ones. Lower β\beta below 0.710.71 and the eigenvector becomes noise; raise it to 3 or 4 and structure appears. Change nn to move the threshold.
[ ]Measured overlap versus BBP limitBrowser
import numpy as np

rng = np.random.default_rng(4)
n, d = 400, 200
g = d / n
u = np.zeros(d)
u[:20] = 1 / np.sqrt(20)
print(" beta   <v1,u>^2 medido (4 muestras)   límite BBP")
for beta in [0.5, 0.75, 1.0, 1.5, 3.0, 8.0]:
    ov = []
    for rep in range(4):
        X = rng.standard_normal((n, d)) + np.sqrt(beta) * np.outer(rng.standard_normal(n), u)
        Xc = X - X.mean(axis=0)
        w, V = np.linalg.eigh(Xc.T @ Xc / n)
        ov.append((V[:, -1] @ u) ** 2)
    lim = (1 - g / beta ** 2) / (1 + g / beta) if beta > np.sqrt(g) else 0.0
    print(f"{beta:5.2f}   {np.mean(ov):8.3f}                        {lim:.3f}")

Far from the threshold the formula is accurate (0.598 versus 0.583 at β=1.5\beta = 1.5; 0.809 versus 0.810 at β=3\beta = 3). Near it finite size matters: at β=1\beta = 1 measured overlap is 0.198 versus limit 0.333 because the transition, abrupt in the limit, smooths over a window of width order n−1/3n^{-1/3} around γ\sqrt\gamma. Below it (β=0.5\beta = 0.5), overlap is 0.03, small and tending to zero as nn grows (a random direction gives 1/d=0.0051/d = 0.005).

Practical rule: before interpreting component loadings, check how far its eigenvalue is from the edge. Near the edge, loadings are mostly noise even if the eigenvalue is significant. An empirical check independent of any model is stability: recompute the component on bootstrap row resamples and inspect how each loading changes.

Cleaning a covariance matrix

For covariance inversion, small eigenvalues are the problem, not large ones. The minimum-variance portfolio of dd assets with covariance Σ\mat{\Sigma} is

w∗=Σ−111⊤Σ−11,R∗=w∗⊤Σw∗=11⊤Σ−11.\vb{w}^* = \frac{\mat{\Sigma}\inv\vb{1}}{\vb{1}\T\mat{\Sigma}\inv\vb{1}}, \qquad R^* = \vb{w}^{*\T}\mat{\Sigma}\vb{w}^* = \frac{1}{\vb{1}\T\mat{\Sigma}\inv\vb{1}} .

Replacing Σ\mat{\Sigma} with Σ^\hat{\mat{\Sigma}} makes portfolio w^\hat{\vb{w}} load on directions where Σ^\hat{\mat{\Sigma}} has small eigenvalues, much smaller than the truth in the proportional regime. Measure two risks: predicted, w^⊤Σ^w^\hat{\vb{w}}\T\hat{\mat{\Sigma}}\hat{\vb{w}}, seen by the portfolio builder, and realized, w^⊤Σw^\hat{\vb{w}}\T\mat{\Sigma}\hat{\vb{w}}, actually incurred.

Proof

Write Σ^=Σ1/2WΣ1/2\hat{\mat{\Sigma}} = \mat{\Sigma}^{1/2}\mat{W}\mat{\Sigma}^{1/2} with W\mat{W} a normalized white Wishart matrix (sample covariance of isotropic data) and a=Σ−1/21\vb{a} = \mat{\Sigma}^{-1/2}\vb{1}. Then 1⊤Σ^−11=a⊤W−1a\vb{1}\T\hat{\mat{\Sigma}}\inv\vb{1} = \vb{a}\T\mat{W}\inv\vb{a}, 1⊤Σ^−1ΣΣ^−11=a⊤W−2a\vb{1}\T\hat{\mat{\Sigma}}\inv\mat{\Sigma}\hat{\mat{\Sigma}}\inv\vb{1} = \vb{a}\T\mat{W}^{-2}\vb{a} and 1/R∗=∥a∥21/R^* = \norm{\vb{a}}^2. The law of W\mat{W} is rotation invariant, so a quadratic form a⊤W−ka\vb{a}\T\mat{W}^{-k}\vb{a} concentrates around ∥a∥21dtr⁡W−k\norm{\vb{a}}^2\frac1d\tr\mat{W}^{-k}, converging to ∥a∥2mk\norm{\vb{a}}^2 m_k with mk=∫x−k  ⁣dρMP(x)m_k = \int x^{-k}\,\dd\rho_{MP}(x). For Marchenko-Pastur with σ2=1\sigma^2 = 1, m1=1/(1−γ)m_1 = 1/(1 - \gamma) and m2=1/(1−γ)3m_2 = 1/(1 - \gamma)^3. Predicted risk is 1/(a⊤W−1a)1/(\vb{a}\T\mat{W}\inv\vb{a}) and its ratio to R∗R^* tends to 1/m1=1−γ1/m_1 = 1 - \gamma; realized risk is a⊤W−2a/(a⊤W−1a)2\vb{a}\T\mat{W}^{-2}\vb{a}/(\vb{a}\T\mat{W}\inv\vb{a})^2, and its ratio tends to m2/m12=1/(1−γ)m_2/m_1^2 = 1/(1 - \gamma).

∎

With γ=0.5\gamma = 0.5, the portfolio promises half the optimal risk and delivers twice it: a factor-4 difference between predicted and realized, despite nothing wrong with the data. The solution is not to use Σ^\hat{\mat{\Sigma}} as-is.

The oracle deserves a line. Among estimators with eigenvectors of Σ^\hat{\mat{\Sigma}}, the closest to Σ\mat{\Sigma} in Frobenius norm uses ξi=v^i⊤Σv^i\xi_i = \hat{\vb{v}}_i\T\mat{\Sigma}\hat{\vb{v}}_i, because ∥∑iξiv^iv^i⊤−Σ∥F2=∑i(ξi−v^i⊤Σv^i)2+(terms independent of ξ)\norm{\sum_i\xi_i\hat{\vb{v}}_i\hat{\vb{v}}_i\T - \mat{\Sigma}}_F^2 = \sum_i(\xi_i - \hat{\vb{v}}_i\T\mat{\Sigma}\hat{\vb{v}}_i)^2 + \text{(terms independent of } \xi). It requires Σ\mat{\Sigma}, but in the proportional regime can be estimated from the sample spectrum alone: Ledoit and Wolf’s (2012) nonlinear shrinkage and Bun, Bouchaud and Potters’ (2017) rotation-invariant estimator derive it from the Marchenko-Pastur Stieltjes transform. In synthetic data below we can calculate the exact oracle as a bound on cleaning that retains eigenvectors.

Ledoit-Wolf intensity minimizes expected squared error in normalized Frobenius norm, ∥A∥2=tr⁡(AA⊤)/d\norm{\mat{A}}^2 = \tr(\mat{A}\mat{A}\T)/d, and is estimated with

δ2=∥Σ^−μI∥2,bˉ2=1n2∑i=1n∥xixi⊤−Σ^∥2,ρ=min⁡(bˉ2,δ2)δ2,\delta^2 = \norm{\hat{\mat{\Sigma}} - \mu\mat{I}}^2, \qquad \bar b^2 = \frac{1}{n^2}\sum_{i=1}^n\norm{\vb{x}_i\vb{x}_i\T - \hat{\mat{\Sigma}}}^2, \qquad \rho = \frac{\min(\bar b^2, \delta^2)}{\delta^2},

with centered xi\vb{x}_i. bˉ2\bar b^2 measures how covariance varies from one observation to another (variance of Σ^\hat{\mat{\Sigma}}), and δ2\delta^2 how far Σ^\hat{\mat{\Sigma}} lies from scaled identity: shrink more when the estimate is noisier relative to existing structure.

InteractiveCleaning portfolio covariance
Minimum-variance portfolio risk / optimum (mean over 8 samples)
1/(1−γ)1−γ
Sorted eigenvalues (one sample with n=200n = 200)
  • sample covariance (dotted: predicted risk)
  • eigenvalue clipping
  • Ledoit-Wolf
  • sample covariance theory / true covariance
200 (γ = 0.50)
Sample covariance: true risk / optimum…
Clipping…
Ledoit-Wolf…
Predicted risk from sample covariance…
Eigenvalues outside the bulk (mean)…
Ledoit–Wolf shrinkage ρ\rho…
Computing the grid…
One hundred assets with a market factor, three sectors and idiosyncratic risk of different variance per asset. Left: realized minimum-variance portfolio risk divided by optimal risk versus γ=d/n\gamma = d/n, for sample covariance (red), clipped (teal) and Ledoit-Wolf (purple); dotted red is risk predicted by sample covariance, and dashed gray curves are theoretical 1/(1−γ)1/(1-\gamma) and 1−γ1-\gamma. Right: sorted sample eigenvalues versus true ones (thick gray): sample spreads them too far apart and cleaned estimates pull them together. Move nn to 110 and 1000 to see which method wins in each regime.

The next section’s lab measures the same with several samples per point. Three results: with γ\gamma near 1 any cleaning greatly improves on sample covariance; with small γ\gamma the sample is nearly optimal and clipping stalls above it because replacing the whole bulk by its mean erases idiosyncratic-risk differences that are real here; and the oracle shows that even retaining sample eigenvectors with the best possible eigenvalues does not reach optimal risk, because eigenvectors themselves are noisy.

Lab: how many components are signal

Four tools from scratch: median matching for σ2\sigma^2, the Marchenko-Pastur edge, permutation parallel analysis and the Gavish-Donoho threshold, applied to the figure’s spiked model.

[ ]Three criteria from scratchBrowser
import numpy as np
from scipy import integrate, optimize

def mp_edges(g, s2=1.0):
    return s2 * (1 - np.sqrt(g)) ** 2, s2 * (1 + np.sqrt(g)) ** 2

def mp_median(g):
    """Mediana de la ley de Marchenko-Pastur con sigma^2 = 1 y gamma <= 1."""
    lo, hi = mp_edges(g)
    dens = lambda x: np.sqrt((hi - x) * (x - lo)) / (2 * np.pi * g * x)
    return optimize.brentq(lambda t: integrate.quad(dens, lo, t)[0] - 0.5, lo, hi)

def sigma2_hat(lam, g):
    """sigma^2 por ajuste de medianas: casi todos los autovalores son ruido."""
    return np.median(lam) / mp_median(g)

def eigs(X):
    Xc = X - X.mean(axis=0)
    return np.linalg.eigvalsh(Xc.T @ Xc / len(X))[::-1]

def parallel_analysis(X, B=10, q=95, rng=None):
    """Referencia de Horn por permutación: cada columna se baraja por separado."""
    rng = rng or np.random.default_rng(0)
    E = np.empty((B, X.shape[1]))
    for b in range(B):
        Xp = np.column_stack([rng.permutation(col) for col in X.T])
        E[b] = eigs(Xp)
    return E.mean(axis=0), np.percentile(E, q, axis=0)

def count_seq(lam, ref):
    """Componentes retenidas: mientras lambda_k supere la referencia del índice k."""
    ref = np.broadcast_to(ref, lam.shape)
    k = 0
    while k < len(lam) and lam[k] > ref[k]:
        k += 1
    return k

def gd_coef(b):
    """lambda*(beta) de Gavish y Donoho para m x n con beta = m/n <= 1."""
    return np.sqrt(2 * (b + 1) + 8 * b / ((b + 1) + np.sqrt(b * b + 14 * b + 1)))

def spiked(n, d, betas, rng):
    U = np.linalg.qr(rng.standard_normal((d, len(betas))))[0]
    F = rng.standard_normal((n, len(betas))) * np.sqrt(betas)
    return F @ U.T + rng.standard_normal((n, d))

rng = np.random.default_rng(1)
n, d = 400, 200
g = d / n
X = spiked(n, d, [8, 4, 2, 1, 0.4], rng)
lam = eigs(X)
m, p95 = parallel_analysis(X, B=10, rng=rng)
s2 = sigma2_hat(lam, g)
print(f"gamma = {g}; umbral BBP sqrt(gamma) = {np.sqrt(g):.3f}; sigma^2 estimada = {s2:.3f}")
print("mayores autovalores:       ", np.round(lam[:6], 3))
print("análisis paralelo (media): ", np.round(m[:6], 3))
print("análisis paralelo (95 %):  ", np.round(p95[:6], 3))
print(f"borde MP: {s2 * mp_edges(g)[1]:.3f};  umbral de Gavish-Donoho en autovalores: {s2 * gd_coef(g) ** 2:.3f}")
print("componentes: PA media", count_seq(lam, m), "| PA 95 %", count_seq(lam, p95),
      "| borde MP", count_seq(lam, s2 * mp_edges(g)[1]), "| Gavish-Donoho", count_seq(lam, s2 * gd_coef(g) ** 2))

The Gavish-Donoho threshold for singular values of X\mat{X} (n×dn \times d, with d≤nd \le n) is λ∗(γ)n σ\lambda^*(\gamma)\sqrt n\,\sigma; since λ^k=sk2/n\hat\lambda_k = s_k^2/n, on the eigenvalue scale it becomes λ∗(γ)2σ2\lambda^*(\gamma)^2\sigma^2, which the cell uses. Of five spikes, four exceed 0.5=0.71\sqrt{0.5} = 0.71; β=1\beta = 1 does so narrowly and its BBP limit is 3.0, just above edge 2.93, so at this size it remains in noise and all three detection criteria count 3. Gavish-Donoho counts 2: the β=2\beta = 2 spike is detectable but below its usefulness threshold.

[ ]Known rank in four regimesBrowser
rng = np.random.default_rng(2)
casos = [(400, 100, [8, 4, 2, 1, 0.4]), (400, 200, [8, 4, 2, 1, 0.4]),
         (400, 400, [8, 4, 2, 1, 0.4]), (400, 200, [60, 1.5, 1.0])]
print(f"{'n':>4} {'d':>4} {'betas':<20} {'detect.':>7} {'PA med':>7} {'PA 95':>6} {'MP':>5} {'GD':>5}")
for n, d, betas in casos:
    g = d / n
    out = []
    for rep in range(3):
        X = spiked(n, d, betas, rng)
        lam = eigs(X)
        m, p95 = parallel_analysis(X, B=5, rng=rng)
        s2 = sigma2_hat(lam, g)
        out.append([count_seq(lam, m), count_seq(lam, p95),
                    count_seq(lam, s2 * mp_edges(g)[1]), count_seq(lam, s2 * gd_coef(g) ** 2)])
    det = sum(b > np.sqrt(g) for b in betas)
    o = np.mean(out, axis=0)
    print(f"{n:>4} {d:>4} {str(betas):<20} {det:>7} {o[0]:>7.2f} {o[1]:>6.2f} {o[2]:>5.2f} {o[3]:>5.2f}")

Each row averages three datasets. The “detect.” column counts spikes with β>γ\beta > \sqrt\gamma. Three interpretations:

  • Horn’s mean overestimates as γ\gamma grows, especially at γ=1\gamma = 1. The cause is an index shift: if there are kk factors, data noise eigenvalues occupy indices k+1,k+2,…k + 1, k + 2, \dots but behave like the first noise eigenvalues, exceeding permuted eigenvalues at those same indices. This over-extraction led Glorfeld (1995) to propose the 95th percentile, partly correcting it.
  • The market factor’s shadow. With β1=60\beta_1 = 60, parallel analysis counts 1 despite 3 factors exceeding threshold; the edge with median-matched σ^2\hat\sigma^2 recovers nearly all. The median is unaffected by the large factor; permutation is not.
  • Gavish-Donoho counts fewer, as it should. It answers a different question: which components help reconstruction. With γ=0.5\gamma = 0.5 it discards the β=2\beta = 2 spike, detectable but too noisy to be useful.

Now cleaning. Clipping operates on correlation, whose noise bulk has mean 1; Ledoit-Wolf shrinkage uses the formula above and is compared with sklearn.covariance.LedoitWolf.

[ ]Clipping and Ledoit-Wolf from scratchBrowser
import numpy as np
from sklearn.covariance import LedoitWolf

def clip_corr(S, n):
    """Recorte de autovalores sobre la correlación: el bulk se sustituye por su media."""
    d = len(S)
    sd = np.sqrt(np.diag(S))
    C = S / np.outer(sd, sd)
    lam, V = np.linalg.eigh(C)
    edge = (1 + np.sqrt(d / n)) ** 2        # la media de los autovalores de C es 1
    bulk = lam <= edge
    lam[bulk] = lam[bulk].mean()            # conserva la traza
    return (V * lam) @ V.T * np.outer(sd, sd)

def ledoit_wolf(X):
    """Contracción lineal hacia mu I con la intensidad de Ledoit y Wolf (2004)."""
    n, d = X.shape
    Xc = X - X.mean(axis=0)
    S = Xc.T @ Xc / n
    mu = np.trace(S) / d
    delta2 = np.sum((S - mu * np.eye(d)) ** 2) / d
    b2 = (np.sum(np.sum(Xc ** 2, axis=1) ** 2) / n - np.sum(S ** 2)) / (n * d)
    rho = min(b2, delta2) / delta2
    return rho * mu * np.eye(d) + (1 - rho) * S, rho

def gmv(S):
    w = np.linalg.solve(S, np.ones(len(S)))
    return w / w.sum()

def factor_model(d, rng):
    """Mercado (varianza 0.04) + tres sectores (0.01) + riesgo idiosincrásico de 0.01 a 0.03."""
    B = np.zeros((d, 4))
    B[:, 0] = 1 + 0.3 * rng.standard_normal(d)
    for k in range(3):
        idx = np.arange(d) % 3 == k
        B[idx, k + 1] = 0.6 + 0.2 * rng.standard_normal(idx.sum())
    fvar = np.array([0.04, 0.01, 0.01, 0.01])
    idio = 0.02 * (0.5 + rng.uniform(size=d))
    return B, fvar, idio

def returns(n, B, fvar, idio, rng):
    return (rng.standard_normal((n, 4)) * np.sqrt(fvar)) @ B.T + rng.standard_normal((n, len(idio))) * np.sqrt(idio)

rng = np.random.default_rng(5)
d = 100
B, fvar, idio = factor_model(d, rng)
Sigma = (B * fvar) @ B.T + np.diag(idio)
X = returns(200, B, fvar, idio, rng)
mine, rho = ledoit_wolf(X)
lw = LedoitWolf().fit(X)
print(f"intensidad de contracción: nuestra {rho:.6f}, sklearn {lw.shrinkage_:.6f}; "
      f"diferencia máxima entre matrices {np.abs(mine - lw.covariance_).max():.1e}")

The implementation matches scikit-learn to rounding. Intensity is small (0.017) because this model’s covariance is dominated by a huge market factor, and distance δ2\delta^2 from scaled identity is large relative to estimation variance. Now compare out of sample, with the oracle as bound:

[ ]Out-of-sample minimum-variance portfolio riskBrowser
def oracle(S, Sigma):
    """Mejor estimador con los autovectores muestrales: xi_i = v_i^T Sigma v_i."""
    lam, V = np.linalg.eigh(S)
    xi = np.einsum("ji,jk,ki->i", V, Sigma, V)
    return (V * xi) @ V.T

w_opt = gmv(Sigma)
r_opt = w_opt @ Sigma @ w_opt
print(f"{'n':>5} {'gamma':>6} {'muestral':>9} {'recorte':>8} {'LW':>6} {'oráculo':>8} {'previsto':>9} {'1/(1-g)':>8}")
for n in [120, 150, 200, 300, 500, 1000]:
    res = []
    for rep in range(5):
        X = returns(n, B, fvar, idio, rng)
        Xc = X - X.mean(axis=0)
        S = Xc.T @ Xc / n
        row = [gmv(Sh) @ Sigma @ gmv(Sh) / r_opt for Sh in [S, clip_corr(S, n), ledoit_wolf(X)[0], oracle(S, Sigma)]]
        row.append(gmv(S) @ S @ gmv(S) / r_opt)
        res.append(row)
    r = np.mean(res, axis=0)
    g = d / n
    print(f"{n:>5} {g:>6.2f} {r[0]:>9.3f} {r[1]:>8.3f} {r[2]:>6.3f} {r[3]:>8.3f} {r[4]:>9.3f} {1 / (1 - g):>8.3f}")

All figures are risk divided by optimal risk, averaged over five samples. Sample and predicted-risk columns follow 1/(1−γ)1/(1 - \gamma) and 1−γ1 - \gamma, as predicted, with five-sample error (0.14 to 0.88 versus 0.17 to 0.90 for predicted). At γ=0.83\gamma = 0.83 sample portfolio risk is almost seven times optimal and clipping reduces it to 1.48, while Ledoit-Wolf reaches 1.97: linear shrinkage toward identity moves all eigenvalues with the same affine rule, and here the whole bulk is the problem. At γ=0.1\gamma = 0.1 sample risk is within 11% of optimal, Ledoit-Wolf matches it, and clipping stalls around 1.30: bias from flattening idiosyncratic variances. The oracle is always below all others, between 1.07 and 1.23.

PCA’s fragility to outliers

Return to the fourth motivation problem. The first component is the principal eigenvector of an average of products xixi⊤\vb{x}_i\vb{x}_i\T, and one point x0\vb{x}_0 enters with weight growing as ∥x0∥2\norm{\vb{x}_0}^2. No sample size can compensate: move one point far enough and the first component points at it. In robust-statistics terms, classical PCA’s breakdown point (fraction of data to corrupt to move the result arbitrarily far) is 1/(n+1)1/(n + 1), tending to 0.

The cleanest case is calculable by hand. Take a cloud of nn points with covariance (dividing by nn), eigenvalues λ1>λ2\lambda_1 > \lambda_2 and axes a\vb{a} and b\vb{b}, and add one point at xˉ+R b\bar{\vb{x}} + R\,\vb{b}, distance RR from center in the direction perpendicular to the principal axis. The new mean shifts by Rb/(n+1)R\vb{b}/(n + 1) and, calculating, the covariance of n+1n + 1 points in basis (a,b)(\vb{a}, \vb{b}) is

nn+1[λ100λ2+R2n+1]\frac{n}{n + 1}\begin{bmatrix} \lambda_1 & 0 \\ 0 & \lambda_2 + \dfrac{R^2}{n + 1} \end{bmatrix}

(if cloud axes are exactly a\vb{a} and b\vb{b}). The first component jumps from a\vb{a} to b\vb{b} when the second entry exceeds the first:

R∗=(n+1)(λ1−λ2).R^* = \sqrt{(n + 1)(\lambda_1 - \lambda_2)} .

With 40 points, λ1≈2\lambda_1 \approx 2 and λ2≈0.08\lambda_2 \approx 0.08, one point about 9 units from center suffices, just over six cloud standard deviations along its long axis. In other directions rotation is gradual rather than a jump, but equally inevitable.

[ ]One point rotates the first componentBrowser
import numpy as np

rng = np.random.default_rng(31)
n = 40
th = np.deg2rad(30)
a = np.array([np.cos(th), np.sin(th)])
b = np.array([-np.sin(th), np.cos(th)])
P = np.outer(1.6 * rng.standard_normal(n), a) + np.outer(0.3 * rng.standard_normal(n), b)
c = P.mean(axis=0)
l1, l2 = np.linalg.eigvalsh(np.cov(P.T, bias=True))[::-1]
print(f"autovalores de la nube: {l1:.3f} y {l2:.3f};  R* = sqrt((n+1)(l1 - l2)) = {np.sqrt((n + 1) * (l1 - l2)):.2f}")

def angle(R):
    Q = np.vstack([P, c + R * b])
    w, V = np.linalg.eigh(np.cov(Q.T, bias=True))
    return np.degrees(np.arccos(abs(V[:, -1] @ a)))

for R in [0, 4, 8, 8.5, 9, 9.5, 12, 20]:
    print(f"R = {R:>4}: PC1 clásica a {angle(R):5.1f} grados del eje")
InteractiveAn outlier rotates the first component
  • PC1 without the outlier (rotation reference)
  • classical PC1
  • robust PCA principal direction
  • outlier (drag it)
  • point with a nonzero outlier term
Robust PCA
Classical PC1 rotation19.7°
Robust direction rotation0.7°
Outlier distance from center7.94
Distance for 45° rotation (in that direction)12.91
Rows with nonzero outlier term3
One point out of 41 rotates classical PC1 by 19.7°. At 12.9 units from the center in this direction, it would turn by 45°.
Forty points around an axis at 30° and a draggable red outlier. The dashed line is PC1 of the forty points without the outlier, the rotation reference. Orange is classical PC1 with the outlier, passing through the mean; teal is robust PCA's principal direction, passing through the median. Initially the outlier, one of 41 points, rotates the classical component about 20° while the robust one barely moves. Move it perpendicular to the axis and find the critical distance shown in the panel; then switch to entrywise robust PCA and inspect its bias even with the outlier next to the cloud.

The figure compares two robust versions defined next, with an instructive difference. The outlier is an entire corrupted row, one bad observation. The rowwise version (outlier pursuit, Xu, Caramanis and Sanghavi, 2010) penalizes the sum of Euclidean norms of outlier rows, invariant to variable-space rotation: it isolates the row and leaves direction intact. The entrywise version (PCP) separately penalizes each entry with the ℓ1\ell_1 norm, which is not rotation invariant, and here every row has noise: it favors distributing residuals along coordinate axes, and on this cloud direction deviates by over ten degrees even without an outlier. It is designed for a different corruption type, individual entries in a large matrix, and two dimensions are outside its domain.

Robust PCA: low rank plus sparse

Many data matrices combine low-rank structure with a few large anomalies: video from a fixed camera (nearly constant background plus moving objects), service metrics (daily and weekly cycles plus incidents), a face database (diffuse lighting plus shadows and highlights). If M=L0+S0\mat{M} = \mat{L}_0 + \mat{S}_0 with low-rank L0\mat{L}_0 and sparse S0\mat{S}_0 of arbitrarily large entries, classical PCA seeks the best low-rank least-squares approximation of M\mat{M} and is pulled by S0\mat{S}_0. Naturally one might seek

min⁡L,S rank⁡(L)+λ∥S∥0subject toL+S=M,\min_{\mat{L}, \mat{S}}\ \rank(\mat{L}) + \lambda\norm{\mat{S}}_0 \quad\text{subject to}\quad \mat{L} + \mat{S} = \mat{M},

where ∥S∥0\norm{\mat{S}}_0 counts nonzero entries. This combinatorial problem is intractable. Convex relaxation replaces each term by its convex envelope on the corresponding unit ball: rank by nuclear norm ∥L∥∗=∑iσi(L)\norm{\mat{L}}_* = \sum_i\sigma_i(\mat{L}), the order-1 Schatten norm (Fazel, 2002, proved it is rank’s convex envelope on the unit spectral norm ball), and ∥⋅∥0\norm{\cdot}_0 by entrywise ℓ1\ell_1 norm.

Both terms are homogeneous of degree 1, so multiplying M\mat{M} by a constant scales the solution by the same constant: λ\lambda does not depend on global units. But it is not invariant to rescaling columns separately: if one variable is in milliseconds and another in fractions, ℓ1\ell_1 treats them as comparable. Therefore robustly standardize each variable (median and median absolute deviation) before applying PCP to heterogeneous units.

When can separation succeed? Not always. If L0=e1e1⊤\mat{L}_0 = \vb{e}_1\vb{e}_1\T, the low-rank matrix is also sparse (one nonzero entry), and nothing distinguishes “low rank” from “anomaly.” If S0\mat{S}_0 corrupts an entire column, the sparse part also has rank 1. Theory excludes both with two assumptions: singular vectors of L0\mat{L}_0 are spread out (incoherence) and the support of S0\mat{S}_0 is randomly distributed.

Remarkably the fraction of corrupted entries can be a constant, not something tending to 0, and corruptions can be arbitrarily large: ℓ1\ell_1 does not average them, it isolates them. The theorem also fixes λ=1/n\lambda = 1/\sqrt n without tuning. For rectangular matrices replace nn by n(1)=max⁡(n1,n2)n_{(1)} = \max(n_1, n_2) in λ\lambda and the logarithm, and by n(2)=min⁡(n1,n2)n_{(2)} = \min(n_1, n_2) in the rank bound. The authors experimentally show random problems with rank 0.05n0.05n and 10% corrupted entries are recovered with relative error below 10−510^{-5}.

Two variants cover what the model leaves out:

  • Entire corrupted observations. If outliers are whole rows (a badly recorded day, a fraudulent customer), the entrywise model is unsuitable: replace ∥S∥1\norm{\mat{S}}_1 by the sum of Euclidean row norms, ∥C∥2,1=∑i∥Ci,:∥2\norm{\mat{C}}_{2,1} = \sum_i\norm{\mat{C}_{i,:}}_2. This is the previous figure’s outlier pursuit, recovering the good-row subspace and identifying corrupted rows.
  • Dense noise. Real data also have small noise in every entry, M=L0+S0+N\mat{M} = \mat{L}_0 + \mat{S}_0 + \mat{N}. Stable PCP (Zhou, Li, Wright, Candès and Ma, 2010) relaxes the constraint to ∥M−L−S∥F≤δ\norm{\mat{M} - \mat{L} - \mat{S}}_F \le \delta and guarantees error bounded by a matrix-size-dependent multiple of δ\delta. The lab shows what happens if you ignore it and a simple way to account for it using the first half’s ideas.

The algorithm: ADMM with two thresholds

PCP is convex but nondifferentiable and has exactly the structure for ADMM: two variable blocks with their own terms, coupled by a linear constraint. The augmented Lagrangian with multiplier Y\mat{Y} and penalty μ>0\mu > 0 is

ℓμ(L,S,Y)=∥L∥∗+λ∥S∥1+⟨Y,M−L−S⟩+μ2∥M−L−S∥F2.\ell_\mu(\mat{L}, \mat{S}, \mat{Y}) = \norm{\mat{L}}_* + \lambda\norm{\mat{S}}_1 + \inner{\mat{Y}}{\mat{M} - \mat{L} - \mat{S}} + \frac\mu2\norm{\mat{M} - \mat{L} - \mat{S}}_F^2 .

Minimizing over L\mat{L} with the rest fixed gives, completing the square, min⁡L∥L∥∗+μ2∥L−(M−S+μ−1Y)∥F2\min_{\mat{L}}\norm{\mat{L}}_* + \frac\mu2\norm{\mat{L} - (\mat{M} - \mat{S} + \mu\inv\mat{Y})}_F^2: the proximal operator of μ−1∥⋅∥∗\mu\inv\norm{\cdot}_*. Minimizing over S\mat{S} is the proximal of λμ−1∥⋅∥1\lambda\mu\inv\norm{\cdot}_1. Both have closed forms.

The first is separable and familiar. You prove the second in a guided exercise at the end; von Neumann’s trace inequality is the key. With both, each ADMM iteration is

Lk+1=D1/μ(M−Sk+μ−1Yk),Sk+1=Sλ/μ(M−Lk+1+μ−1Yk),Yk+1=Yk+μ(M−Lk+1−Sk+1).\begin{aligned} \mat{L}^{k+1} &= \mathcal{D}_{1/\mu}\big(\mat{M} - \mat{S}^k + \mu\inv\mat{Y}^k\big), \\ \mat{S}^{k+1} &= \mathcal{S}_{\lambda/\mu}\big(\mat{M} - \mat{L}^{k+1} + \mu\inv\mat{Y}^k\big), \\ \mat{Y}^{k+1} &= \mat{Y}^k + \mu\big(\mat{M} - \mat{L}^{k+1} - \mat{S}^{k+1}\big). \end{aligned}

Candès, Li, Ma and Wright use μ=n1n2/(4∥M∥1)\mu = n_1n_2/(4\norm{\mat{M}}_1), S0=Y0=0\mat{S}^0 = \mat{Y}^0 = \mat{0} and stop when ∥M−L−S∥F≤10−7∥M∥F\norm{\mat{M} - \mat{L} - \mat{S}}_F \le 10^{-7}\norm{\mat{M}}_F. Convergence follows from two-block ADMM for convex problems. Cost is dominated by an SVD per iteration, potentially partial since only singular values above 1/μ1/\mu matter. Interpret it: the L\mat{L} update is PCA with a threshold (as in Gavish-Donoho, but soft) and S\mat{S} declares anomalous what deviates from it by more than λ/μ\lambda/\mu.

InteractiveBackground and objects with robust PCA
Frame t=1t = 1 of M\mat{M}
Low-rank L\mat{L} (background)
Sparse S\mat{S} (red +, blue −)
Full transposed matrices M=L+S\mat{M} = \mat{L} + \mat{S}. Each row is one frame (432 pixels). The outline marks the current frame.
M\mat{M}
L\mat{L}
S\mat{S}
× 1.00
frame 1 of 40
λ\lambda0.0481
ADMM iterations…
Relative residual…
Rank of L\mat{L}…
Nonzero entries in S\mat{S}…
Object entries…
Relative background error…
Precision and recall…
Solving…
Forty 24×1824\times18 frames: a fixed background with oscillating global brightness (therefore rank 1) and two objects crossing it. Each frame is a column of M\mat{M} (432×40432\times40). Above: current frame, its low-rank part and sparse part (lighter gray means higher value; in S\mat{S}, red positive and blue negative). Below: the three entire matrices transposed, one frame per row: L\mat{L} repeats the same background with varying brightness and S\mat{S} reveals object trajectories. ADMM runs live and panels show its state. Play with λ=1/432\lambda = 1/\sqrt{432}: separation is exact. Then move λ\lambda to extremes: small λ\lambda leaks background into S\mat{S}; large λ\lambda leaves object trails in L\mat{L}, which needs many components to explain them.

Lab: robust PCA with ADMM

First the implementation, checked on its intended problem: a random low-rank matrix with 5% of entries corrupted by very large values.

[ ]PCP with ADMM from scratchBrowser
import numpy as np

def svt(X, t):
    """Proximal de t ||.||_*: umbral suave de los valores singulares."""
    U, s, Vt = np.linalg.svd(X, full_matrices=False)
    s = np.maximum(s - t, 0)
    r = int((s > 0).sum())
    return (U[:, :r] * s[:r]) @ Vt[:r], r

def soft(X, t):
    """Proximal de t ||.||_1: umbral suave entrada a entrada."""
    return np.sign(X) * np.maximum(np.abs(X) - t, 0)

def pcp(M, lam=None, tol=1e-7, maxit=500):
    """Principal component pursuit por ADMM con los parámetros de Candès, Li, Ma y Wright."""
    n1, n2 = M.shape
    lam = lam if lam is not None else 1 / np.sqrt(max(n1, n2))
    mu = n1 * n2 / (4 * np.abs(M).sum())
    S = np.zeros_like(M)
    Y = np.zeros_like(M)
    nM = np.linalg.norm(M)
    for k in range(1, maxit + 1):
        L, r = svt(M - S + Y / mu, 1 / mu)
        S = soft(M - L + Y / mu, lam / mu)
        R = M - L - S
        Y += mu * R
        if np.linalg.norm(R) <= tol * nM:
            break
    return L, S, {"iter": k, "rango": r, "residuo": np.linalg.norm(R) / nM}

rng = np.random.default_rng(6)
n, r = 150, 7
L0 = rng.standard_normal((n, r)) @ rng.standard_normal((r, n)) / np.sqrt(n)
mask = rng.uniform(size=(n, n)) < 0.05
amp = 5 * np.abs(L0).max()
S0 = np.where(mask, rng.choice([-1.0, 1.0], size=(n, n)) * amp, 0.0)
L, S, info = pcp(L0 + S0)
print(f"n = {n}, rango {r}, {mask.mean():.1%} de entradas corruptas de amplitud {amp:.2f}")
print(f"iteraciones {info['iter']}, rango de L {info['rango']}, "
      f"error relativo de L {np.linalg.norm(L - L0) / np.linalg.norm(L0):.1e}, "
      f"soporte de S acertado en {np.mean((np.abs(S) > 1e-3) == mask):.2%} de las entradas")
U, s, Vt = np.linalg.svd(L0 + S0, full_matrices=False)
L1 = (U[:, :r] * s[:r]) @ Vt[:r]
print(f"PCA clásica de rango {r} (sabiendo el rango): error relativo {np.linalg.norm(L1 - L0) / np.linalg.norm(L0):.2f}")

PCP recovers L0\mat{L}_0 with relative error below 10−610^{-6} in 36 iterations and identifies every entry’s support. Classical PCA, even knowing rank, has relative error 2.5: corruptions outweigh signal. The figure’s video:

[ ]Background and objectsBrowser
def video(H=18, W=24, T=40):
    """Fondo con iluminación variable (rango 1) y dos objetos en movimiento; un fotograma por columna."""
    yy, xx = np.mgrid[0:H, 0:W]
    bg = 0.3 + 0.4 * xx / W + 0.1 * np.sin(yy / 3)
    bg[3:9, 4:10] = 0.85
    bg[11:16, 14:21] = 0.15
    illum = 1 + 0.15 * np.sin(2 * np.pi * np.arange(T) / (T - 1))
    F = bg[None] * illum[:, None, None]
    L0 = F.reshape(T, -1).T.copy()
    for t in range(T):
        for y0, x0, h, w, val in [(6, (27 * t) // 40 - 3, 4, 3, 1.0), (13 - t // 6, W - 1 - (3 * t) // 5, 3, 3, 0.0)]:
            F[t, max(0, y0):min(H, y0 + h), max(0, x0):min(W, x0 + w)] = val
    return F.reshape(T, -1).T, L0

M, L0 = video()
truth = np.abs(M - L0) > 0.02
print(f"M: {M.shape}, rango del fondo {np.linalg.matrix_rank(L0)}, objetos en {truth.mean():.1%} de las entradas")
for f in [0.25, 1.0, 2.0]:
    L, S, info = pcp(M, lam=f / np.sqrt(M.shape[0]), maxit=150)
    det = np.abs(S) > 0.02
    prec = (det & truth).sum() / max(det.sum(), 1)
    rec = (det & truth).sum() / truth.sum()
    print(f"lambda = {f:>4} / sqrt(432): {info['iter']:>3} iteraciones, rango(L) = {info['rango']}, "
          f"error del fondo {np.linalg.norm(L - L0) / np.linalg.norm(L0):.1e}, precisión {prec:.3f}, recall {rec:.3f}")

With the theorem’s λ\lambda and twice that value, separation is exact in about twenty iterations: background error is order 10−710^{-7} and precision and recall are 1. With λ\lambda four times smaller, ADMM does not converge in 150 iterations and half the sparse part is false positives (precision 0.53). Candès and coauthors’ original experiment does the same with real video: 200 airport frames of 176×144176\times144, a 25 344×20025\,344\times200 matrix.

Service metrics with incidents. Thirty hourly series over two weeks: latency (milliseconds), error rate (fraction) and CPU use (%) for ten services, all with daily cycles and weekend effects, plus 3% noise and six injected incidents sized between 6 and 40 noise standard deviations. One is large: a whole service degraded for 12 hours. For classical PCA and PCP, flag residuals exceeding 4 column median absolute deviations as anomalous.

[ ]Metrics with incidents: classical PCA versus PCPBrowser
def metrics(seed=7):
    """30 métricas (latencia en ms, tasa de error, CPU en %) de 10 servicios, cada hora durante dos semanas."""
    rng = np.random.default_rng(seed)
    T, ns = 336, 10
    t = np.arange(T)
    daily = np.sin(2 * np.pi * t / 24)
    weekend = (t // 24 % 7 >= 5).astype(float)
    cols = []
    for s in range(ns):
        a = 0.6 + 0.4 * rng.uniform()
        b = rng.uniform()
        cols += [120 * (1 + 0.3 * a * daily - 0.2 * b * weekend),
                 0.01 * (1 + 0.5 * a * daily - 0.3 * b * weekend),
                 50 * (1 + 0.4 * a * daily - 0.25 * b * weekend)]
    L0 = np.column_stack(cols)
    sd = 0.03 * np.abs(L0).mean(axis=0)
    X = L0 + rng.standard_normal(L0.shape) * sd
    truth = np.zeros(X.shape, bool)
    # (servicio, hora de inicio, duración, métricas afectadas, tamaño en desviaciones del ruido)
    incidentes = [(2, 100, 12, [0, 1, 2], 40), (5, 30, 3, [1], 8), (7, 200, 4, [0, 2], 10),
                  (1, 260, 2, [2], 12), (8, 150, 6, [0], 6), (4, 300, 3, [1, 2], 9)]
    for s, t0, dur, js, mag in incidentes:
        for j in js:
            X[t0:t0 + dur, 3 * s + j] += mag * sd[3 * s + j]
            truth[t0:t0 + dur, 3 * s + j] = True
    return X, truth

def robust_scale(X):
    med = np.median(X, axis=0)
    return (X - med) / (1.4826 * np.median(np.abs(X - med), axis=0))

def flag(R, c=4.0):
    """Marca |residuo| > c MAD por columna."""
    dev = np.abs(R - np.median(R, axis=0))
    return dev > c * 1.4826 * np.median(dev, axis=0)

def score(det, truth):
    tp = (det & truth).sum()
    return f"precisión {tp / max(det.sum(), 1):.3f}, recall {tp / truth.sum():.3f}"

X, truth = metrics()
Z = robust_scale(X)
print(f"{X.shape[0]} horas x {X.shape[1]} métricas; {truth.sum()} celdas anómalas ({truth.mean():.1%})")
Zc = Z - Z.mean(axis=0)
U, s, Vt = np.linalg.svd(Zc, full_matrices=False)
print("valores singulares:", s[:5].round(1))
print("métricas con más peso en la segunda componente:", np.argsort(-np.abs(Vt[1]))[:3], "(servicio 2: columnas 6, 7, 8)")
for k in [1, 2]:
    R = Zc - (U[:, :k] * s[:k]) @ Vt[:k]
    print(f"PCA clásica de rango {k}: {score(flag(R), truth)}")
L, S, info = pcp(Z, maxit=400)
print(f"PCP con lambda = 1/sqrt(336): rango(L) = {info['rango']}, {score(flag(Z - L), truth)}")

Classical PCA fails in both possible ways. At rank 1 it omits part of normal structure (weekend effect varies by service) and flags it anomalous (precision 0.34). At true rank 2, the second component is not the weekend but the large incident: its three largest loadings are service 2’s three metrics, and once absorbed into the “normal” model it stops being anomalous, as do small incidents sharing its direction. Recall is 0.38. PCP detects everything, but with precision 0.68 and rank-17 L\mathbf{L}: model M=L0+S0\mat{M} = \mat{L}_0 + \mat{S}_0 has no dense noise, and PCP can explain 3% noise in every entry only by distributing it between a high-rank part and a part that is not sparse.

The correction uses the lesson’s first half. Add a fitting term, min⁡ ∥L∥∗+λ∥S∥1+12τ∥M−L−S∥F2\min\ \norm{\mat{L}}_* + \lambda\norm{\mat{S}}_1 + \frac{1}{2\tau}\norm{\mat{M} - \mat{L} - \mat{S}}_F^2, and minimize by blocks: L=Dτ(M−S)\mat{L} = \mathcal{D}_\tau(\mat{M} - \mat{S}), S=Sλτ(M−L)\mat{S} = \mathcal{S}_{\lambda\tau}(\mat{M} - \mat{L}). This is exact block descent on a convex function whose nondifferentiable term separates blocks, and converges (Tseng, 2001). To choose τ\tau, require noise alone not to pass the singular-value threshold: the largest singular value of σZ\sigma\mat{Z} (n1×n2n_1\times n_2) is approximately σ(n1+n2)\sigma(\sqrt{n_1} + \sqrt{n_2}), the bulk edge, so τ=σ(n1+n2)\tau = \sigma(\sqrt{n_1} + \sqrt{n_2}). Estimate σ\sigma using Gavish-Donoho median matching.

[ ]Robust PCA with dense noise, and why scaling mattersBrowser
def stable_pcp(M, sigma, lam=None, iters=200):
    """Rango bajo + disperso + ruido denso: umbral de L en el borde del bulk, sigma (sqrt(n1) + sqrt(n2))."""
    n1, n2 = M.shape
    lam = lam if lam is not None else 1 / np.sqrt(max(n1, n2))
    tau = sigma * (np.sqrt(n1) + np.sqrt(n2))
    S = np.zeros_like(M)
    for _ in range(iters):
        L, r = svt(M - S, tau)
        S = soft(M - L, lam * tau)
    return L, S, r

def sigma_hat(M):
    """sigma por la mediana de los valores singulares (n1 >= n2): s^2/n1 sigue Marchenko-Pastur con gamma = n2/n1."""
    n1, n2 = M.shape
    return np.median(np.linalg.svd(M, compute_uv=False)) / np.sqrt(n1 * mp_median(n2 / n1))

tipo = np.arange(30) % 3
def por_tipo(det):
    return "; ".join(f"{nom} {(det & truth)[:, tipo == k].sum()}/{truth[:, tipo == k].sum()} "
                     f"(falsas {(det & ~truth)[:, tipo == k].sum()})" for k, nom in enumerate(["latencia", "errores", "CPU"]))

sig = sigma_hat(Z)
L, S, r = stable_pcp(Z, sig)
print(f"escalado robusto: sigma = {sig:.4f}, rango(L) = {r}, {score(flag(Z - L), truth)}")
print("   |S| > 3 sigma:", por_tipo(np.abs(S) > 3 * sig))
Xm = X - np.median(X, axis=0)
sig = sigma_hat(Xm)
L, S, r = stable_pcp(Xm, sig)
print(f"sin escalar:      sigma = {sig:.4f}, rango(L) = {r}")
print("   |S| > 3 sigma:", por_tipo(np.abs(S) > 3 * sig))

With scaled data, the noise-aware variant returns rank-2 L\mat{L}, the true rank, and detects incidents with precision and recall 0.97. The sparse part directly detects anomalies: flagging ∣Sij∣>3σ^\abs{S_{ij}} > 3\hat\sigma finds all 61 incidents with 12 false alarms. Without scaling, the same procedure seems to work (rank 2), but global scale σ^\hat\sigma is set by latency in milliseconds: error rates of 0.01 never reach the S\mat{S} threshold, their 18 anomalous cells go unnoticed, and latency accumulates over two hundred false alarms. This is the mistake of choosing λ\lambda and threshold without scaling first.

Common mistakes

Exercises

NumericThe bulk edge
You have d=100d = 100 variables and n=400n = 400 observations of unit-variance white noise. Above what value must a sample covariance eigenvalue lie to be outside the Marchenko-Pastur bulk?
NumericThe Gavish-Donoho threshold
A 400×400400\times400 matrix has Gaussian noise with known standard deviation σ=0.5\sigma = 0.5 per entry. What is the optimal Gavish-Donoho hard threshold for its singular values?
QuizThe smallest eigenvalue when d = n
You have unit-variance white noise with as many variables as observations, d=nd = n, both large. What happens to the smallest sample covariance eigenvalue?
QuizParallel analysis assumptions
Parallel analysis generates its reference by independently permuting each data column. Which statements are true? (Several may apply.)

More than one answer may be correct.

NumericHow similar is the eigenvector?
In the spiked model Σ=I+βuu⊤\mat{\Sigma} = \mat{I} + \beta\vb{u}\vb{u}\T with γ=d/n=0.25\gamma = d/n = 0.25 and β=1\beta = 1, what does ⟨v^1,u⟩2\inner{\hat{\vb{v}}_1}{\vb{u}}^2 approach?
QuizKeep a visible component?
You reconstruct a large square matrix Y=X+σZ\mat{Y} = \mat{X} + \sigma\mat{Z} by truncated SVD. One component has signal x=1.5x = 1.5 in units of n σ\sqrt n\,\sigma. What should you do?
NumericWhat the portfolio promises and delivers
You build the minimum-variance portfolio of 250 assets using sample covariance from 500 days of Gaussian returns. In the proportional limit, how many times greater is realized (out-of-sample) risk than predicted (in-sample) risk?
NumericHow far before an outlier dominates?
A cloud of n=99n = 99 points in the plane has covariance (dividing by nn) with eigenvalues λ1=4\lambda_1 = 4 and λ2=1\lambda_2 = 1 along axes a\vb{a} and b\vb{b}. Add a point at distance RR from center in direction b\vb{b}. Beyond what RR does the first component of 100 points become b\vb{b}?
QuizCan it be separated?
In which case is recovering L0\mat{L}_0 and S0\mat{S}_0 from M=L0+S0\mat{M} = \mat{L}_0 + \mat{S}_0 impossible even in principle?
QuizUnits and lambda
You apply PCP with λ=1/max⁡(n1,n2)\lambda = 1/\sqrt{\max(n_1, n_2)} to a metrics matrix. What changes the solution?
ProofThe nuclear norm proximal operator
Prove: For A=Udiag⁡(a)V⊤∈Rn1×n2\mat{A} = \mat{U}\operatorname{diag}(\vb{a})\mat{V}\T \in \R^{n_1\times n_2} (SVD with a1≥⋯≥aq≥0a_1 \ge \dots \ge a_q \ge 0, q=min⁡(n1,n2)q = \min(n_1, n_2)) and t>0t > 0, the unique minimizer of f(X)=t∥X∥∗+12∥X−A∥F2f(\mat{X}) = t\norm{\mat{X}}_* + \frac12\norm{\mat{X} - \mat{A}}_F^2 is Dt(A)=Udiag⁡(max⁡(ai−t,0))V⊤\mathcal{D}_t(\mat{A}) = \mat{U}\operatorname{diag}\big(\max(a_i - t, 0)\big)\mat{V}\T.
0
Let s(X)\vb{s}(\mat{X}) be the vector of singular values of X\mat{X} in decreasing order.

Step 1 of 4. Which inequality compares ∥X−A∥F\norm{\mat{X} - \mat{A}}_F to something depending only on singular values?

CodeClip the bulk
Implement clip_covariance(S, n): accept a d×dd\times d sample covariance S computed from n observations and return the clipped matrix. Use γ=d/n\gamma = d/n, noise variance σ2=tr⁡(S)/d\sigma^2 = \operatorname{tr}(S)/d and edge λ+=σ2(1+γ)2\lambda_+ = \sigma^2(1 + \sqrt\gamma)^2; retain eigenvalues above λ+\lambda_+, replace the others by their mean (preserving trace), and retain eigenvectors. Tests check structure and out-of-sample minimum-variance portfolio risk in a one-factor model with γ=0.8\gamma = 0.8.
import numpy as np

def clip_covariance(S, n):
  """Recorte de autovalores: el bulk de Marchenko-Pastur se sustituye por su media."""
  S = np.asarray(S, dtype=float)
  d = S.shape[0]
  # tu código: autodescomposición, borde, sustitución del bulk, reconstrucción
  return S.copy()
Shift+Enter to run

Summary

  • With dd comparable to nn, sample covariance misleads predictably: pure noise occupies bulk [σ2(1−γ)2,σ2(1+γ)2][\sigma^2(1 - \sqrt\gamma)^2, \sigma^2(1 + \sqrt\gamma)^2], signal is visible only if β>γ\beta > \sqrt\gamma (BBP transition), and even then its eigenvalue is biased and eigenvector only partly aligned, ⟨v^,u⟩2→(1−γ/β2)/(1+γ/β)\inner{\hat{\vb{v}}}{\vb{u}}^2 \to (1 - \gamma/\beta^2)/(1 + \gamma/\beta).
  • How many components depends on the question. For detection: the Marchenko-Pastur edge with median-matched σ2\sigma^2 or Horn’s parallel analysis, each with its null (isotropic noise; independent columns) and failures (heteroscedasticity; strong-factor shadow, dependent noise, over-extraction with the mean). For reconstruction: Gavish-Donoho threshold (4/3)n σ(4/\sqrt3)\sqrt n\,\sigma for square matrices, discarding visible components with signal below 3\sqrt3.
  • Loadings of a component near the edge are mostly noise: do not interpret them without checking distance to edge or stability.
  • Cleaning covariance (clipping, Ledoit-Wolf, nonlinear shrinkage) corrects the mismatch between predicted (1−γ)R∗(1 - \gamma)R^* and realized R∗/(1−γ)R^*/(1 - \gamma) sample-portfolio risk. No method wins everywhere, and the oracle with sample eigenvectors sets the limit.
  • Classical PCA has zero breakdown point. Robust PCA separates M=L+S\mat{M} = \mat{L} + \mat{S} with nuclear norm plus ℓ1\ell_1 (PCP), recovers exactly under incoherence and random support with λ=1/max⁡(n1,n2)\lambda = 1/\sqrt{\max(n_1, n_2)}, and uses ADMM alternating singular-value and entrywise soft thresholds. Include dense noise in the model and scale heterogeneous units first.
Key idea
An eigenvalue means something only compared with what noise would produce, and a component is useful only if its signal exceeds not the noise edge but the threshold at which it contributes more than it distorts. Robust PCA applies the same idea to outliers: instead of averaging them, it separates them into a sparse part with its own cost.