Skip to content

Johnson–Lindenstrauss lemma

Posted on:

Take nn points in a Euclidean space of any dimension DD, and fix a tolerance ε(0,1)\varepsilon \in (0, 1). The Johnson–Lindenstrauss lemma says there is a linear map into dimension

k  =  O ⁣(lognε2)k \;=\; O\!\left(\frac{\log n}{\varepsilon^2}\right)

that changes every pairwise distance by a factor of at most 1±ε1 \pm \varepsilon. Two features deserve a double take. The target dimension kk does not involve the source dimension DD at all: a million points in D=109D = 10^9 compress exactly as well as a million points in D=103D = 10^3. And the dependence on nn is only logarithmic: squaring the number of points merely doubles kk.

Better still, the map is oblivious: it is a random projection drawn without looking at the data, and it works for any point set with high probability. This is a different contract from PCA, which studies the data first and preserves global variance directions with no guarantee for any individual pair; the lemma guarantees every pair, and never reads the data. The proof below is the elementary one of Dasgupta and Gupta, and it is two moves long: a tail bound for a single vector, then a union bound.

The statement

Let AA be a random k×Dk \times D matrix with independent N(0,1/k)\mathcal{N}(0, 1/k) entries. For nn points x1,,xnRDx_1, \ldots, x_n \in \mathbb{R}^D and

k    4lnnε2/2ε3/3,k \;\ge\; \frac{4 \ln n}{\varepsilon^2/2 - \varepsilon^3/3},

with positive probability the map f(x)=Axf(x) = Ax satisfies, for every pair i,ji, j,

(1ε)xixj2    f(xi)f(xj)2    (1+ε)xixj2.(1 - \varepsilon)\, \|x_i - x_j\|^2 \;\le\; \|f(x_i) - f(x_j)\|^2 \;\le\; (1 + \varepsilon)\, \|x_i - x_j\|^2 .

One vector at a time

The map is linear, so f(xi)f(xj)=A(xixj)f(x_i) - f(x_j) = A(x_i - x_j): the lemma’s requirement is exactly that AA preserve the squared norms of the (n2)\binom{n}{2} vectors xixjx_i - x_j up to the factor 1±ε1 \pm \varepsilon. Rescaling changes nothing, since A(cv)=cAvA(cv) = c\,Av multiplies Av2\|Av\|^2 and v2\|v\|^2 by the same c2c^2, so each of these vectors may be divided by its length. Everything then rests on a single claim: for one fixed unit vector uRDu \in \mathbb{R}^D, the squared image Au2\|Au\|^2 lies within ε\varepsilon of 1 with high probability.

Each coordinate of AuAu is a Gaussian linear combination, (Au)i=jAijujN(0,1/k)(Au)_i = \sum_j A_{ij} u_j \sim \mathcal{N}(0, 1/k), and the kk coordinates are independent since they come from disjoint rows. This is the 2-stability of the Gaussian: projecting any unit vector, in any dimension, produces the same distribution, which is the source of the lemma’s indifference to DD. Consequently

kAu2    χk2,k\,\|Au\|^2 \;\sim\; \chi^2_k,

a chi-square with kk degrees of freedom: mean kk, so EAu2=1\mathbb{E}\|Au\|^2 = 1, exactly the right scale. What remains is concentration, and the chi-square is generous with its moment generating function: EetZ=(12t)k/2\mathbb{E}\,e^{tZ} = (1 - 2t)^{-k/2} for Zχk2Z \sim \chi^2_k, t<1/2t < 1/2. The Chernoff recipe, exponentiate, apply Markov, optimize tt, runs in closed form. For the upper tail, t=ε2(1+ε)t = \tfrac{\varepsilon}{2(1+\varepsilon)} gives

P(Z(1+ε)k)    [(1+ε)eε]k/2,\mathbb{P}\bigl(Z \ge (1+\varepsilon)k\bigr) \;\le\; \bigl[(1+\varepsilon)\,e^{-\varepsilon}\bigr]^{k/2},

and symmetrically P(Z(1ε)k)[(1ε)eε]k/2\mathbb{P}(Z \le (1-\varepsilon)k) \le [(1-\varepsilon)\,e^{\varepsilon}]^{k/2}. The elementary inequalities ln(1+ε)εε2/2+ε3/3\ln(1+\varepsilon) \le \varepsilon - \varepsilon^2/2 + \varepsilon^3/3 and ln(1ε)εε2/2\ln(1-\varepsilon) \le -\varepsilon - \varepsilon^2/2 turn both brackets into a single clean exponential:

P(Au21>ε)    2exp ⁣(k2(ε22ε33)).\mathbb{P}\Bigl( \bigl|\, \|Au\|^2 - 1 \,\bigr| > \varepsilon \Bigr) \;\le\; 2 \exp\!\left( -\frac{k}{2} \left( \frac{\varepsilon^2}{2} - \frac{\varepsilon^3}{3} \right) \right).

One unit vector survives projection except with exponentially small probability in kk.

The union bound and the constant

A union bound turns the single-vector tail into a statement about all pairs. There are (n2)n2/2\binom{n}{2} \le n^2/2 vectors xixjx_i - x_j to preserve, so the probability that any pair is distorted beyond 1±ε1 \pm \varepsilon is at most

n2exp ⁣(k2(ε22ε33)),n^2 \exp\!\left( -\frac{k}{2} \left( \frac{\varepsilon^2}{2} - \frac{\varepsilon^3}{3} \right) \right),

which drops below 1 exactly when k>4lnn/(ε2/2ε3/3)k > 4\ln n \,/\, (\varepsilon^2/2 - \varepsilon^3/3), and below n2γn^{-2\gamma} when kk carries the extra factor (1+γ)(1+\gamma). That is the whole proof, and it exposes the anatomy of the constant: the per-pair failure probability must be pushed below 1/n21/n^2, an exponential tail converts that demand into 2lnn2 \ln n in the exponent, and the ε2\varepsilon^2 in the tail is the curvature of the chi-square around its mean. The logn\log n in the lemma is not geometry; it is the price of a union bound, paid in dimensions.

The numbers

The bound is explicit, so it can be evaluated at concrete values of nn and ε\varepsilon:

points n = 10⁶
tolerance ε = 0.10
target dimension k = 11,842

For n=106n = 10^6 points at ε=0.1\varepsilon = 0.1 the bound asks for k11,800k \approx 11{,}800 dimensions, and the ε2\varepsilon^{-2} factor is the term that controls the cost: halving the tolerance quadruples kk, while relaxing it to ε=0.2\varepsilon = 0.2 brings the same million points down to about 3,2003{,}200. In the other direction, the figures hold whether the points live in a thousand dimensions or a billion, and pushing nn from a million to a trillion only doubles them. The bound is also worst-case over all point sets and demands every pair simultaneously; practice routinely uses smaller kk and measures the distortion it actually gets, which for natural data is usually gentler than the guarantee.

There is a pleasant symmetry with the usual complaints about high dimensions. Concentration of measure is the villain in the story where nearest-neighbor distances stop being informative and the reason Gaussian samples crowd onto a thin spherical shell; here the same phenomenon is the entire mechanism, harnessed rather than suffered: the projection works precisely because a chi-square with kk degrees of freedom concentrates hard around its mean.

Variants and the lower bound

The Gaussian matrix is the cleanest to analyze, not the cheapest to use, and a line of work has replaced it while preserving the guarantee. Achlioptas showed entries drawn uniformly from ±1\pm 1 work, as does a version with two thirds of the entries zero: no Gaussian sampling, integer arithmetic, the same kk up to constants. Ailon and Chazelle’s fast transform preconditions with a randomized Hadamard matrix so the projection takes roughly DlogDD \log D time instead of kDkD. Kane and Nelson pushed sparsity to a handful of nonzeros per column. On the applications side, the lemma is a workhorse wherever pairwise Euclidean geometry must survive compression: approximate nearest-neighbor search, where it entered algorithm design through Indyk and Motwani; sketching and streaming; and, through the restricted isometry property, the recovery guarantees of compressed sensing, where a JL-style bound applied to all sparse vectors at once plays the starring role.

For thirty years the nagging question was whether the ε2logn\varepsilon^{-2} \log n was an artifact of the union-bound proof. It is not. Larsen and Nelson proved in 2017 that for every nn and ε\varepsilon there are point sets for which any embedding into kk dimensions with distortion 1±ε1 \pm \varepsilon, linear or not, requires k=Ω(ε2logn)k = \Omega(\varepsilon^{-2} \log n). The elementary argument above is optimal up to the constant: two moves, and no cleverness left on the table.

A little history

The lemma was never meant to headline. Johnson and Lindenstrauss proved it in a 1984 paper on a question in functional analysis, whether Lipschitz maps defined on nn-point subsets of a metric space extend to the whole space into Hilbert space with controlled norm growth, and the dimension-reduction statement was a lemma en route, proved there with random orthogonal projections. Frankl and Maehara tightened the constants in 1988. The result crossed into computer science in the late 1990s, most visibly through Indyk and Motwani’s 1998 work on approximate nearest neighbors, and Dasgupta and Gupta’s 2003 note stripped the proof down to the chi-square computation given above. Larsen and Nelson’s 2017 optimality theorem closed the gap between what the union bound pays and what geometry demands, a rare case of a two-step argument from the 1980s being the final word.

References



Next Post
Kelly criterion