Sketching, Johnson–Lindenstrauss and random matrix theory
Before this lesson: lesson 09 (PCA and randomized SVD), lesson 12 (QR and least squares) and lesson 17 (perturbation theory: Weyl and Davis–Kahan). Time: about 90 minutes, plus the notebook.
Why this matters #
Some matrices are too big to factor, or even to read many times. A sketch multiplies the data by a short random matrix and works with the small result. The randomized SVD of lesson 09 was the first example. The same idea solves huge least-squares problems and compresses embeddings and gradients.
Randomness also explains noise. With ensemble members and grid points, the sample covariance of an ensemble forecast is mostly sampling noise. Random matrix theory says exactly how pure noise looks, so you can tell which eigenvalues or singular values carry signal. This replaces "look for the elbow" in a PCA or EOF analysis by a rule with a reason.
1. Predict first #
2. The picture #
One vector first. Fix and draw with independent entries. Then , so is an unbiased estimate of . It is a bad estimate: its relative standard deviation is . Now use independent rows, stacked as . The average is still unbiased, and its relative standard deviation is : 0.1 for .
So a random map keeps one length with error about , whatever is. The tails are close to Gaussian, so the probability of a large error falls exponentially in . This is why we can keep distances at once with only : a union bound over events multiplies the failure probability by , and in the exponent this is only an extra term .
Project 50 points from to . The histogram shows, for all 1225 pairs, the squared distance after the projection divided by the squared distance before. The violet curve is its exact law : it does not depend on the points or on . Move : the spread shrinks like . Below , Theorem 3 (without the term) gives no ; above it the aqua lines show , and the whole histogram almost always stays inside them (press New points a few times: the union bound is pessimistic).
A random projection keeps all pairwise distances of points within with rows when the points live in . The same points are now embedded in (extra zero coordinates, or a finer grid). Which does the JL bound ask for now?
For one fixed vector, , and this law does not contain at all. The union bound counts pairs of points, not coordinates. So depends on (through ) and on (through ), never on .
A whole subspace. A -dimensional subspace holds infinitely many vectors. But its unit sphere is covered by a finite net of points (every unit vector is close to one of them), so it behaves like vectors. Then "" becomes , and a sketch needs rows. Section 3 shows this with a figure.
Noise has a shape. Estimate a covariance from samples in dimensions. If is not small, the sample eigenvalues spread out, even when all true eigenvalues are equal. The spread is deterministic as : the Marchenko–Pastur law. A true signal direction is visible only if its eigenvalue sticks out of this "bulk".
Pure noise is not flat. Each data set has samples of independent features, so every true eigenvalue is 1. The histogram pools the eigenvalues of from four data sets; the violet curve is the Marchenko–Pastur density for . Move : the bulk widens to , and for part of the spectrum is exactly 0. Then add a spike (Theorem 5 below): its orange top eigenvalues leave the bulk only when .
3. Definitions and main results #
Subspace embeddings #
Start with a picture. Take a plane (a 2-dimensional subspace) inside and its unit circle: all vectors of the plane with length 1. A sketch maps each of them to a vector . If we draw each at the length , the circle becomes an ellipse. A good sketch gives an ellipse that is almost round.
Move and watch the ellipse. The dashed circle is the set of unit vectors of the plane. The orange ellipse shows the same vectors at the length ; its half-axes are the singular values of . The aqua ring is the band . Drag the blue vector: its image (violet) always lies on the ellipse. For , the ellipse leaves the ring in about one draw out of three at , and almost never at . Press New S a few times, or Run 1000 draws to count.
From the picture to the formula, step by step. Let have orthonormal columns that span the subspace .
- Every is for one , and because .
- Then , with the small matrix .
- "All lengths are kept within " means for every .
- By the Rayleigh quotient (lesson 06), this holds exactly when every eigenvalue of lies in , that is, .
- The eigenvalues of are the squared singular values of . So every singular value of lies in : the ellipse lies in the ring.
Definition. Let be a subspace and . A matrix is an -subspace embedding for if, for all ,
By steps 1–5, this is the same as . A random is oblivious if it works with probability for any fixed of dimension , without looking at the data.
Three standard sketches for a -dimensional subspace (rows up to constant factors, for a fixed failure probability ; is the number of nonzero entries of ):
| Sketch | What is | Rows (order) | Cost of , |
|---|---|---|---|
| Gaussian | , | , dense: | |
| SRHT | random signs, then a fast Hadamard transform, then random rows | ||
| CountSketch | each row of is added, with a random sign, to one random bucket |
The Gaussian sketch needs the fewest rows but is the most expensive to apply. CountSketch is the cheapest to apply (one pass over the nonzeros) but needs more rows.
Exact row counts and the SRHT
Woodruff (2014), Theorems 6, 7 and 9, give these sizes for an -subspace embedding of a -dimensional subspace with probability at least :
| Sketch | What is | Rows |
|---|---|---|
| Gaussian | , | |
| SRHT | : random signs , normalized Walsh–Hadamard (entries ), sampled rows | |
| CountSketch | one per column, in a random row |
Why the SRHT needs and : uniform row sampling alone fails when a few rows carry most of the energy (a vector like ). The random signs and the Hadamard transform spread the energy of every vector over all coordinates, so that sampling rows uniformly becomes safe.
Two ways to use a sketch for least squares #
We want with and . There are two ways to use a sketch:
| Sketch-and-solve | Sketch-and-precondition | |
|---|---|---|
| What it does | solves the small problem | uses only to build ; then runs LSQR on the full problem with the preconditioner |
| Accuracy | residual within a factor of the optimum; itself can be far off | full accuracy (machine precision), like a direct solver |
| Cost | one sketch + one small QR | one sketch + one small QR + about 30 cheap iterations, each one product with and |
| When to use | you need a good fit (a small residual), not exact coefficients | you need accurate coefficients , or is ill-conditioned |
The next two theorems explain both rows of "Accuracy".
Theorem 1 (sketch-and-solve least squares) #
Let , , and . Let be an -subspace embedding for (dimension at most ), and . Then
Proof.
- For every , the vector lies in , so the embedding bounds apply to it.
- Lower bound at : .
- minimizes the sketched problem: .
- Upper bound at : .
- Chain 2–4 and take square roots.
For small the factor is about . The guarantee is about the residual, not about . Since , Pythagoras gives , so
With a large residual and an ill-conditioned (small ), can be far from : section 5 shows a 170% error. For a Gaussian sketch the average is known exactly: .
You fit a least-squares model with sketch-and-solve, . The matrix has condition number and the optimal residual is not small. What does Theorem 1 promise?
, so the residual is near-optimal for every . But the error in is bounded only by , and a small makes this large. To get an accurate , use the sketch as a preconditioner instead.
Theorem 2 (sketch-and-precondition) #
Let be an -subspace embedding for and a thin QR (). Then , where is the 2-norm condition number (lesson 13).
In words: undoes almost all of the bad scaling of . The matrix has nearly orthonormal columns, whatever was.
Proof of Theorem 2
- has orthonormal columns, so for every .
- , so the embedding gives .
- Divide by : lies in for every . So every singular value of lies in this interval, and their ratio is at most .
Now run LSQR (CG on the normal equations, done stably) on and set . With , the error after iterations is at most times its start value (Woodruff §2.6, Eq. (15)). Even a crude sketch with gives and a factor per iteration: about 27 iterations to reach , whatever is. This reaches full accuracy because the sketch only builds the preconditioner; the iteration solves the original problem. Blendenpik and LSRN work this way.
Theorem 3 (Johnson–Lindenstrauss) #
Let , , . Let have independent entries and . If
then with probability at least , for all pairs :
So , independent of .
Proof, step by step. Each step has the numbers for points, and , where the bound asks for .
- Reduce to one vector. is linear, so . It suffices to show that for each fixed unit vector (the normalized difference), satisfies , except with a small probability. Numbers: there are difference vectors.
- Exact distribution. Row of gives , and the rows are independent. So is a sum of squared standard normals: , . Numbers: we want in .
- Chernoff, upper tail. For and , . By Markov's inequality applied to , . Choose , so . The bound becomes .
- Use : . Numbers: , and .
- Lower tail, the same way with and : , using . This is no larger than the bound of step 4. Numbers: one pair fails with probability at most .
- Union bound. There are fewer than pairs, each failing with probability at most . The total is at most , which is exactly when satisfies the bound above. Numbers: .
The bound is pessimistic. For , the exact probability of leaving is about , about 60 times smaller than the Chernoff bound of step 5. This is why the histogram in section 2 almost always stays inside the aqua lines.
Remarks.
- The map is oblivious: it does not look at the data, unlike PCA.
- Inner products survive too. By , if keeps the squared norms of , then for unit .
- The cannot be improved, even by nonlinear maps (Vershynin, Remark 5.3.4), and Larsen and Nelson (2017) showed that as a whole is optimal (for not extremely small).
- Random signs ( entries), sparse JL matrices and the fast JL transform (the SRHT) give the same guarantee, up to constants, at lower cost.
- With an -point net on the unit sphere of a -dimensional subspace, the same proof gives the Gaussian row of the table: .
The Marchenko–Pastur law #
Setup. has independent entries with mean 0 and variance : samples (rows), features. The sample covariance is (), and the aspect ratio is .
Theorem 4 (Marchenko–Pastur 1967). As with , the histogram of the eigenvalues of converges to the density
on , where . For this is the whole law. For this part has mass , and a point mass sits at 0 ( has rank at most ).
What to read from it:
- The mean of the law is : the trace is right, but the eigenvalues spread around it.
- The spread is set by alone. For () the support shrinks to .
- Singular values of itself fill about . Non-asymptotic version for Gaussian entries: (Vershynin, Theorem 7.3.1).
- With a finite fourth moment, the largest eigenvalue converges to . Its fluctuations are of relative order (the Tracy–Widom law), so the edge is sharp.
- Link to lesson 17: for , . Weyl's inequality then lets each sample eigenvalue move by up to this amount.
You have samples of independent features, all with variance 1. Where do the eigenvalues of lie (approximately)?
, so and the Marchenko–Pastur support is . The width is set by , not by : even with 9 samples per feature, the largest sample eigenvalue is about 4 times the smallest.
Theorem 5 (spiked covariance, BBP phase transition). Let the rows have covariance , with and spike strength . As above, with :
- If : the top sample eigenvalue converges to , and the top sample eigenvector satisfies .
- If : the top eigenvalue sticks to , and .
Two lessons: a signal weaker than is undetectable by PCA, and a detected signal is biased: the sample eigenvalue is too large and the eigenvector is tilted (Davis–Kahan in action). In the figure of section 2, set and move across .
More on the BBP transition
- Where the threshold comes from. Write . Its derivative is zero at , where . So the formula for the top eigenvalue touches the bulk edge exactly at the threshold. Below it the formula would rise again (for example for ), but it no longer describes an eigenvalue: the top eigenvalue stays at the edge.
- The overlap is 0 at and tends to 1 as . Near the threshold the eigenvalue is visible but the eigenvector is almost useless.
- Sources. Baik, Ben Arous and Péché (2005) for the eigenvalue (complex Gaussian data), Baik and Silverstein (2006) and Paul (2007) for real data and the eigenvector.
- Finite samples. At finite the top noise eigenvalue fluctuates around on the Tracy–Widom scale , and the transition is smooth instead of sharp.
How to decide if a top eigenvalue is signal. A step list for a sample covariance with samples and features:
- Compute .
- Estimate the noise variance : from data with no signal, or from the bulk (for example the median eigenvalue compared with the median of the MP law).
- Compute the bulk edge .
- An eigenvalue clearly above (with a margin for finite- fluctuations) is signal. Everything at or below is consistent with pure noise.
- For a detected eigenvalue , remove the bias. Set and solve for : . The true variance in that direction is , not .
- A direction you cannot see may still exist: it is only known that . More samples (smaller ) lower the threshold.
Signal plus noise for one data matrix. Let be with , , of low rank and with independent entries. The noise singular values fill . A rule to separate:
- Estimate (from a noise-only region, or from the median singular value).
- Keep the singular values above the bulk edge (plus a margin): below it, signal and noise cannot be told apart.
- If the goal is the smallest mean squared error of , use the slightly higher Gavish–Donoho threshold , with for square matrices (2.858 times the median singular value when is unknown). Components just above the edge are real but so noisy that keeping them increases the error.
For a square matrix and a rank-one signal of size , the observed top singular value is about if , and stays at the edge if .
High-dimensional geometry and superposition #
- Norms concentrate. For , (Vershynin §3.1): random vectors live near a sphere.
- Random directions are almost orthogonal. For independent uniform unit vectors , has mean 0 and variance , and . The union bound of the JL proof then gives directions with all ; equivalently, random directions have . In you get about 20,000 directions with , but only 1000 exactly orthogonal ones.
- Superposition (Elhage et al. 2022): a network can represent more features than it has dimensions by giving each feature an almost-orthogonal direction. The price is interference . It pays off when features are sparse (rarely active together), and a nonlinearity such as ReLU filters out the small interference. A consequence: features need not align with single neurons. This is why interpretability work uses sparse autoencoders to find them.
Raise the dimension. Left: the norms of 300 random Gaussian vectors , divided by . Right: the angles between the 4950 pairs among 100 of them. The violet curves are the exact densities. As grows, stays at with a standard deviation of about , whatever is, so piles up at 1. The angles pile up at with a spread of about . In every angle is equally likely; in no pair is more than a few degrees from orthogonal.
You draw many pairs of random directions in (for example two token embeddings at initialization). What do the angles between them look like?
has mean 0 and variance , so its standard deviation is . One radian is , so the angle spreads by about around . A spread of would fit .
Answers to section 1. (1) No. depends only on and : with , (about 2,660 for a 99% guarantee), the same for or . (2) , so about : a factor 9 between the smallest and the largest, although all true eigenvalues are 1.
4. Worked example #
(a) JL dimension. points, . Then and , so : . This is the bound without the term (the form scikit-learn uses). With the exact number of pairs it still guarantees success with probability at least , and in practice the union bound is very pessimistic. For a real guarantee, adds to the numerator: . With and : . The is expensive; the is cheap.
(b) A tiny CountSketch. Fit a constant: , . The exact answer is the mean, , with . Hash rows 1, 3 to bucket 1 and rows 2, 4 to bucket 2, with signs :
The sketched problem gives , and : the residual is times the optimum. This distorts by , so Theorem 1 only promises . Two buckets for a 2-dimensional subspace is far too few; real sketches use .
(c) Noise or signal? samples, features, , so and .
- Noise bulk: eigenvalues of in ; singular values of in .
- Spike (true variance 4 along ): , so it is detected. The top sample eigenvalue is about , not 4, and , an angle of about 19°. Going back (step 5 of the step list): , , and . ✓
- Spike (true variance 1.4): , so it is invisible. The top eigenvalue stays at about 2.25, and is unrelated to .
- So with 1000 samples, a direction with 40% more variance than the others cannot be found by PCA at all. Four times more samples (, threshold 0.25) would reveal it.
A data set has samples of features with noise variance 1. One direction has extra variance (covariance ). For which can PCA detect it, for large and ?
The BBP threshold is . Below it, the top sample eigenvalue sticks to the bulk edge and the top eigenvector carries no information about . The edge is a threshold for the observed eigenvalue, not for .
5. In code #
NumPy, SciPy and scikit-learn check the claims of sections 3 and 4. The notebook for this lesson has these cells (at smaller sizes) and the exercises.
import numpy as np
from scipy.spatial.distance import pdist
from scipy.sparse.linalg import LinearOperator, lsqr
from scipy.linalg import solve_triangular
from sklearn.random_projection import GaussianRandomProjection, johnson_lindenstrauss_min_dim
rng = np.random.default_rng(0)
# 1) JL: 500 points in D = 10_000 dimensions, eps = 0.25.
n, D, eps = 500, 10_000, 0.25
k = johnson_lindenstrauss_min_dim(n, eps=eps) # the bound of Theorem 3 with delta = 1
X = rng.standard_normal((n, D))
Y = GaussianRandomProjection(n_components=k, random_state=0).fit_transform(X)
ratio = pdist(Y, "sqeuclidean") / pdist(X, "sqeuclidean")
print(k, ratio.min().round(3), ratio.max().round(3)) # 954 0.814 1.246: inside [0.75, 1.25]
# 2) Sketch-and-solve vs sketch-and-precondition, kappa(A) = 1e6.
m, d, ks = 20_000, 50, 500
A = rng.standard_normal((m, d)) @ np.diag(np.logspace(0, -6, d))
b = A @ rng.standard_normal(d) + 1e-3 * rng.standard_normal(m)
x_opt = np.linalg.lstsq(A, b, rcond=None)[0]
S = rng.standard_normal((ks, m)) / np.sqrt(ks) # dense Gaussian sketch
x_sk = np.linalg.lstsq(S @ A, S @ b, rcond=None)[0]
res = lambda x: np.linalg.norm(A @ x - b)
rel = lambda x: np.linalg.norm(x - x_opt) / np.linalg.norm(x_opt)
print(res(x_sk) / res(x_opt), rel(x_sk)) # 1.044 (theory: E ratio^2 = 1 + d/(k-d-1) = 1.11), 1.73
R = np.linalg.qr(S @ A, mode="r")
AR = LinearOperator((m, d), matvec=lambda y: A @ solve_triangular(R, y),
rmatvec=lambda z: solve_triangular(R, A.T @ z, trans="T"))
print(np.linalg.cond(A), np.linalg.cond(solve_triangular(R, A.T, trans="T").T)) # 1e6 -> 1.9
y, istop, iters = lsqr(AR, b, atol=1e-14, btol=1e-14, iter_lim=500)[:3]
print(iters, rel(solve_triangular(R, y))) # 28 iterations, error ~3e-12
print(lsqr(A, b, atol=1e-14, btol=1e-14, iter_lim=500)[2]) # 500: no preconditioner, no convergence
# 3) Marchenko-Pastur: pure noise, then one spike of strength theta.
n, p = 1000, 250
gamma = p / n
Z = rng.standard_normal((n, p))
ev = np.linalg.eigvalsh(Z.T @ Z / n)
print(ev.min().round(3), ev.max().round(3), (1 - gamma**0.5)**2, (1 + gamma**0.5)**2)
v = np.zeros(p); v[0] = 1.0
for theta in [3.0, 0.4]:
Xs = Z + (np.sqrt(1 + theta) - 1) * np.outer(Z @ v, v) # covariance I + theta v v^T
w, V = np.linalg.eigh(Xs.T @ Xs / n)
print(theta, w[-1].round(3), (V[:, -1] @ v)**2) # 3.0: ~4.4, ~0.91; 0.4: ~2.24, ~0
# 4) Rank-3 signal + noise (500 x 500, sigma = 1): which singular values are signal?
N = 500
U0 = np.linalg.qr(rng.standard_normal((N, 3)))[0]
V0 = np.linalg.qr(rng.standard_normal((N, 3)))[0]
Yn = U0 @ np.diag([60.0, 30.0, 18.0]) @ V0.T + rng.standard_normal((N, N))
s = np.linalg.svd(Yn, compute_uv=False)
print(s[:5].round(1), round(2 * N**0.5, 1), round(4 / 3**0.5 * N**0.5, 1))
# [67.1 47.2 44. 43.7 43.4] edge 44.7 Gavish-Donoho 51.6
# 5) Near-orthogonality: 4000 random unit vectors in R^1000.
W = rng.standard_normal((4000, 1000))
W /= np.linalg.norm(W, axis=1, keepdims=True)
G = W @ W.T
np.fill_diagonal(G, 0)
print(np.abs(G).max().round(3), np.sqrt(4 * np.log(4000) / 1000).round(3)) # 0.157 <= 0.182
Part 2: the residual is near-optimal but is off by 170%, because ; the same sketch as a preconditioner gives full accuracy. Part 4: the signal singular values are in units of , so theory predicts observed values , and "at the edge" (). The bulk-edge rule keeps two components, Gavish–Donoho keeps one, and the third is undetectable.
6. Where it shows up #
- Large least squares and low-rank approximation. Sketch-and-precondition solvers (Blendenpik, LSRN) for ; the randomized SVD (lesson 09) sketches the range with ; streaming PCA keeps only a sketch.
- Embeddings and gradients. Random projection before nearest-neighbor search; TRAK (Park et al. 2023) compresses per-example gradients with a JL projection for data attribution.
- Ensemble data assimilation. With members for a state of size , the sample covariance has rank at most 49 and spurious long-range correlations. Localization, inflation and shrinkage (Ledoit–Wolf) are the fixes.
- Choosing the number of EOFs or POD modes. Compare the singular values with the noise bulk edge, or use the Gavish–Donoho threshold, instead of an "elbow" by eye.
- Neural networks. For a random initial weight matrix , the eigenvalues of (the squared singular values) follow the MP law; trained layers show outliers above the bulk and heavy tails, which carry learned structure (Martin and Mahoney, JMLR 2021). Superposition motivates sparse autoencoders in interpretability.
7. Common mistakes #
- Using sketch-and-solve when you need . It controls the residual only. For an accurate , sketch-and-precondition.
- A dense Gaussian sketch on dense data. Forming costs , more than the of Householder QR when . Use SRHT or CountSketch for speed; Gaussian is for analysis and for small problems.
- Forgetting the scaling, or applying the JL bound for points to a whole subspace (infinitely many points): a subspace needs .
- Believing is small for small . costs dimensions. JL helps when is huge; for 768-dimensional embeddings, PCA or quantization is often better.
- Reading sample eigenvalues as population eigenvalues when is not small, or mixing up with .
- Treating a value just above as certain signal. Finite- (Tracy–Widom) fluctuations, a wrong , or correlated noise move the edge.
8. Check yourself #
- Use the bound of Theorem 3 for points and ( not counted). Does the answer
change for ?
Answer
. It does not depend on , so for JL gives no reduction at all: use a larger , or PCA. - A sketch has on . Bound the
sketch-and-solve residual, and for .
Answer
Both by : the residual is at most 22.5% above the optimum, and . - Why does the JL dimension grow like and not like ?
Answer
One distance fails with probability (exponential tail of ). A union bound over fewer than pairs multiplies this by , which is absorbed when . - samples, features, noise variance 1. Where is the noise bulk of
? Is a spike visible? Give the predicted top eigenvalue and squared overlap.
Answer
: bulk . , so yes: top eigenvalue , and . - is with . Give the bulk edge and the
Gavish–Donoho threshold. Do you keep an observed singular value of 7.0?
Answer
Edge ; . The value 7.0 is clearly above the edge, so it is almost surely real signal, but it is below : for the smallest mean squared error, drop it (its singular vectors are too noisy to help). - How can a 1000-dimensional residual stream hold features with little interference?
Answer
Random directions are almost orthogonal: random unit vectors in have . If the features are sparse, few are active at once, so the interference stays small, and a nonlinearity can remove it.
Define an -subspace embedding for the subspace with orthonormal basis .
for all in the subspace; equivalently .
What does sketch-and-solve least squares guarantee, and what does it not guarantee?
: a near-optimal residual. It does not guarantee that is close to (ill-conditioned ).
What is the idea of sketch-and-precondition?
Use the sketch only to compute from . Then , and LSQR on the full problem converges fast to full accuracy.
State the Johnson–Lindenstrauss lemma (the size of ).
with keeps all squared pairwise distances of points within , with high probability; does not depend on the dimension .
Why does the JL dimension grow like ?
One distance fails with probability . A union bound over fewer than pairs only adds to the exponent.
Pure noise, variance , : where are the eigenvalues of ?
In the Marchenko–Pastur support .
When can PCA detect a spike (covariance ), and where is the top eigenvalue then?
Only when . The top eigenvalue tends to , above the bulk edge.
How long is a random Gaussian vector ?
, with a standard deviation of about , whatever is.
Compute the typical spread of the angle between two random directions in .
around .
Rank the Gaussian, SRHT and CountSketch by the cost of computing for .
CountSketch < SRHT < dense Gaussian .
9. Interview angle #
- "State and prove JL." — concentration for one vector by Chernoff, then a union bound over pairs: , independent of .
- "How do you solve least squares with rows and 100 columns?" — Sketch (SRHT or CountSketch) to a few times rows, QR of as a preconditioner, then LSQR: about work plus the small QR, and full accuracy.
- "Random projection or PCA?" — JL is oblivious, cheap and keeps every pairwise distance up to , with set by . PCA adapts to the data and is optimal on average for rank , but gives no worst-case guarantee for single pairs.
- "Is this eigenvalue of my covariance signal?" — Compare with the MP edge ; spikes below are undetectable, and detected ones are biased upward.
10. Practice #
The notebook for this lesson runs in Colab. It has five exercises, each with a check cell and a folded solution:
- Write
jl_min_dim(n, eps, delta)from Theorem 3 and compare it with scikit-learn. - Write a Gaussian random projection and measure the distortion of all pairwise distances against and the JL .
- Sketch-and-solve least squares: check the residual factor of Theorem 1 and see how far is from for an ill-conditioned .
- Sketch-and-precondition: build from the QR of , check , and solve to full accuracy with LSQR.
- Signal or noise: compute the Marchenko–Pastur edges and the BBP prediction, and count the singular values of a noisy low-rank matrix above the bulk edge.
11. Watch and read #
- Roman Vershynin, High-Dimensional Probability, 2nd ed. (free PDF): §3.1 (concentration of the norm), §5.3 (Theorem 5.3.1, the JL lemma, and Remark 5.3.4 on optimality), §4.6 and §7.3 (Theorems 4.6.1 and 7.3.1, singular values of random matrices).
- David Woodruff, Sketching as a Tool for Numerical Linear Algebra (2014): §2.1 (Definitions 1–2, Theorems 6, 7, 9), §2.5 (Theorem 21, regression) and §2.6 (sketch-and-precondition).
- Gavish and Donoho, The Optimal Hard Threshold for Singular Values is 4/√3 (IEEE Trans. Inf. Theory 2014): §I (the bulk edge and the threshold), Eq. (11) and Table I for .
- Elhage et al., Toy Models of Superposition (Anthropic, 2022): "Definitions and Motivation" (the superposition hypothesis) and "Demonstrating Superposition".
Runs in your browser with nothing to install. The notebook repeats the key demos and has exercises with checks; solutions are inside, folded.
No Google account needed: Python runs inside your browser. The first start downloads about 40 MB; your changes are saved in this browser only.