For and any points in a Hilbert space, there is a linear map into Euclidean dimension that multiplies every pairwise distance by a factor between and .
The striking feature is that the target dimension depends on the number of points and the allowed error, independently of the ambient dimension. Fix a finite set , with , and . An equivalent sufficient statement uses squared Euclidean distances: a linear map exists, with , such thatThe finite-set theorem cited here supplies an explicit sufficient target dimension for this squared-distance formulation. [ref]
An elementary proof of a theorem of Johnson and Lindenstrauss by Sanjoy Dasgupta and Anupam Gupta. An elementary proof of a theorem of Johnson and Lindenstrauss, Theorem 2.1, p. 61: bounds for squared distances
Taking square roots gives distance factors and , which lie inside . Conversely, bounds on distances only give squared-distance bounds ; the same numerical tolerance should not be silently used for both. Under the squared-distance bounds, the bi-Lipschitz distortion is at most .
The Johnson–Lindenstrauss lemma preserves this fixed finite set, rather than every vector in the ambient Euclidean space. A linear map with has a nonzero kernel by the rank-nullity theorem, so some nonzero vectors collapse completely. For finitely many points in a real Hilbert space, apply the finite-dimensional argument on their linear span and extend by orthogonal projection onto that linear span. If the sufficient target dimension exceeds the ambient dimension, the identity map already preserves every Euclidean distance exactly, with zero padding if a larger target is requested.
Draw a random matrix whose entries are independent random variables with the standard normal distribution, and setThe factor makes the expected value of the squared L2 norm equal to the original squared L2 norm. This Gaussian Johnson–Lindenstrauss transform is a linear map, generally not an orthogonal projection: its rows are not required to be orthogonal vectors. [ref]
Lecture notes on metric embeddings by Jiří Matoušek. Lecture notes on metric embeddings, §2.1(b), p. 21, and Lemma 2.3.1, p. 24: independent Gaussian coefficients and normalization
For the fixed finite set , let be an allowed failure probability, and defineWith denoting the natural logarithm, a sufficient integer target dimension isThen one draw of this specified random matrix satisfies all the squared Euclidean distance bounds simultaneously with probability at least . Since , the simpler sufficient bound also works. Both are sufficient bounds for this argument; they do not claim the smallest possible target dimension.
This is a probability statement about a map drawn independently of the fixed finite set. It implies existence because the success probability is positive, but permits failed draws. The set cannot be chosen after inspecting the map with this same guarantee. In particular, no single draw preserves every possible finite set in the ambient Euclidean space when .
Here is an original reproducible finite set with 40 points and 512 coordinates. Let be the first four vectors of the standard basis of . With point indices , generateThe four groups have different centers, and the standard normal random variables perturb all 512 coordinates. Generate the coordinates in row order using NumPy's PCG64 pseudorandom number generator with seed 20261013. Then keep this finite set fixed. A second PCG64 stream with seed 424242 generates a matrix of independent random variables with the standard normal distribution; divide it by to obtain the Gaussian Johnson–Lindenstrauss transform.
For all 780 unordered pairs, compute the distance ratio . In this draw, its minimum is approximately and its maximum , giving a maximum relative error in Euclidean distance of about . The squared-distance ratios instead range from approximately to : their maximum relative error is about . Thus this particular draw fails a 20% distance tolerance. The Johnson–Lindenstrauss lemma does not assert that every draw into 32 dimensions must succeed.
The two bands of original Euclidean distances distinguish pairs within a group from pairs between groups. Their spread after the linear map shows why checking an average distance is insufficient: the Johnson–Lindenstrauss lemma controls every pair. The dashed 20% distance band is an illustrative tolerance, not a confidence interval or a squared-distance band. The affine hull of 40 points has dimension at most 39; 512 is the ambient coordinate count, and no full-dimensionality assumption is required. For this draw the bi-Lipschitz distortion is approximately .
Now keep the same points and draw 48 fresh Gaussian Johnson–Lindenstrauss transforms for each target dimension . NumPy's
SeedSequence(314159).spawn(240) supplies distinct PCG64 streams, ordered first by target dimension, then by draw. Each stream generates a new random matrix, normalized by ; no map is a row prefix of another map. Each plotted value isThe observed median maximum relative errors in Euclidean distance are approximately , , , , and , respectively. All pairs fall inside the 20% distance tolerance in , , , , and of the 48 draws, respectively. These are computations on one synthetic finite set, rather than optimal dimension bounds or measured physical data. The displayed quantiles describe the sampled maps; they do not certify a success probability for other sets. Even at 128 dimensions, 13 of the sampled maps fail this tolerance.
The practical benefit is that each point acquires fewer coordinates while its pairwise Euclidean distances can remain useful. The choice of target dimension balances compression, accuracy, and failure probability. For example, a conservative sufficient squared-distance tolerance with and gives by the explicit bound above. Here that exceeds the ambient dimension, so the identity map is better for a certified guarantee. The much smaller dimensions in the plots illustrate observed behavior without claiming that this sufficient bound is sharp.
A short concentration inequality argument explains the bound. For a fixed nonzero vector , the normalized row products are independent random variables with the standard normal distribution, soUse the moment-generating function of a chi-squared distribution and the Chernoff bound to obtainFor , elementary logarithm inequalities bound their sum by . Apply the union bound to the nonzero pair differences to get failure probability at most . Independence of different pairs is unnecessary; they use the same map. This combines fixed-vector concentration with a finite-set union bound. [ref]
Lecture notes on metric embeddings by Jiří Matoušek. Lecture notes on metric embeddings, §2.1, pp. 20–21, and proof of Lemma 2.3.1, pp. 25–26: fixed-vector concentration and union bound over pair differences
The unit sphere of an -dimensional normed space has a -net of size at most . If on this net and , then
If has independent Rademacher entries, then for fixed and ,Applying a union bound to all pairwise differences embeds fixed points into dimension while preserving every squared distance within a factor with probability at least .
For a standard normal variable and ,The exponential Markov inequality consequently gives Gaussian concentration for averages of independent copies of .
The random matrixsatisfiesA net argument shows that permits a linear embedding of distortion below .
Every -point metric space embeds into with distortion . Apply the Bourgain embedding theorem, reduce its Euclidean dimension to with the Johnson–Lindenstrauss lemma, and use an Almost-isometric Gaussian embedding from l2 into l1.
Articles by others on the same topic
The Johnson–Lindenstrauss (JL) lemma is a result in mathematics and computer science that states that a set of high-dimensional points can be embedded into a lower-dimensional space in such a way that the distances between the points are approximately preserved. More formally, the lemma asserts that for any set of points in a high-dimensional Euclidean space, there exists a mapping to a lower-dimensional Euclidean space that maintains the pairwise distances between points within a small factor.

