Random Projections: Exponential Concentration of Squared Gaussians
Math 123: Mathematical Aspects of Data Analysis — Fall 2026
We begin with a probability question: how tightly does the average of \(k\) squared standard Gaussians concentrate around its mean? Let \[ Z_k=\frac1k\sum_{r=1}^kg_r^2=\frac Sk, \qquad g_1,\ldots,g_k\text{ independent }N(0,1). \] Here \(S=\sum_{r=1}^k g_r^2\) is the sum of the squared standard Gaussian variables, so \(Z_k=S/k\) is their average squared value. This page visualises the Gaussian concentration theorem and explains why exponential decay is useful when many events must succeed at once. In the next example, we will show that each pair’s squared-distance distortion under a Gaussian random projection has exactly the distribution of \(Z_k\). That will let us use this theorem to prove the Johnson–Lindenstrauss lemma.
Figure style
import plotly.graph_objects as go
from plotly.subplots import make_subplots
INK = "#7c7c78"
GRID = "rgba(128, 128, 128, 0.28)"
BLUE, ORANGE, TEAL = "#2a78d6", "#eb6834", "#27a9a0"
CONFIG = dict(displayModeBar=False, responsive=True)
def style(fig, height=460, title=None, showlegend=None):
"""Apply the shared layout to a plot with axes."""
fig.update_layout(
template="simple_white",
paper_bgcolor="rgba(0,0,0,0)",
plot_bgcolor="rgba(0,0,0,0)",
font=dict(color=INK, size=13),
title=dict(text=title, x=0, xanchor="left", font=dict(size=15)),
margin=dict(l=60, r=30, t=60 if title else 40, b=50),
height=height,
showlegend=showlegend,
hovermode="closest",
)
fig.update_xaxes(gridcolor=GRID, linecolor=GRID, zerolinecolor=GRID)
fig.update_yaxes(gridcolor=GRID, linecolor=GRID, zerolinecolor=GRID)
return fig
def slider(values, start, prefix):
"""A Plotly slider that jumps between the frames named str(v) for v in values."""
return [dict(
active=start, x=0.05, len=0.9, y=-0.14,
currentvalue=dict(prefix=prefix, font=dict(size=15)),
pad=dict(t=25), tickcolor=GRID,
steps=[dict(label=str(v), method="animate",
args=[[str(v)], dict(mode="immediate", frame=dict(duration=0, redraw=True),
transition=dict(duration=0))])
for v in values],
)]Mean and variance of \(Z_k\)
Since \(\Ebb[g_r^2]=1\) and \(\operatorname{Var}(g_r^2)=2\), independence gives \[ \Ebb[Z_k]=\frac1k\sum_{r=1}^k\Ebb[g_r^2]=1, \qquad \operatorname{Var}(Z_k)=\frac1{k^2}\sum_{r=1}^k\operatorname{Var}(g_r^2)=\frac2k. \] Thus the mean stays at \(1\), while the standard deviation \(\sqrt{2/k}\) shrinks as \(k\) grows. Figure 1 illustrates this using \(5{,}000\) independent samples of \(Z_k\) for each \(k\). Each sample is computed directly by averaging \(k\) squared standard Gaussians.
Plot the mean and standard deviation
fig = make_subplots(rows=1, cols=2, horizontal_spacing=0.12,
subplot_titles=("mean of Z<sub>k</sub>", "standard deviation of Z<sub>k</sub>"))
fig.add_trace(go.Scatter(x=ks_m, y=np.ones_like(means), mode="lines", name="1",
line=dict(color=INK, width=1.2, dash="dot"), showlegend=False), row=1, col=1)
fig.add_trace(go.Scatter(x=ks_m, y=means, mode="markers", name="simulated",
marker=dict(color=BLUE, size=9)), row=1, col=1)
fig.add_trace(go.Scatter(x=ks_m, y=np.sqrt(2 / ks_m), mode="lines", name="√(2/k)",
line=dict(color=ORANGE, width=2, dash="dash")), row=1, col=2)
fig.add_trace(go.Scatter(x=ks_m, y=sds, mode="markers", showlegend=False,
marker=dict(color=BLUE, size=9)), row=1, col=2)
style(fig, height=400, showlegend=True)
fig.update_layout(legend=dict(orientation="h", x=0, y=-0.2))
fig.update_xaxes(type="log", title_text="k")
fig.update_yaxes(range=[0, 1.5], row=1, col=1)
fig.update_yaxes(type="log", row=1, col=2)
fig.show(config=CONFIG)The shrinking standard deviation describes the typical spread. For random projections, we will need a bound on the probability of a rare, large deviation.
Why do we need something this strong? Chebyshev’s inequality already gives \(\Pr(|Z_k-1|\geq\epsilon)\leq2/(k\epsilon^2)\). To see what the application will require, suppose we want to preserve all \(N=\binom n2\) pairwise distances with total failure probability at most \(\delta\). The union bound asks each pair to fail with probability at most \(\delta/N\). For \(n=1000\) and \(\delta=0.05\) that is about \(10^{-7}\). A bound that decays like \(1/k\) reaches \(10^{-7}\) only when \(k\) is of order \(N\); a bound that decays like \(e^{-ck}\) gets there when \(k\) is of order \(\log N\).
Exponential decay in \(k\)
Figure 2 plots the failure probability \(\Pr(|Z_k-1|\geq\epsilon)\) against \(k\) on a log scale. The solid line is exact, computed from the chi-squared distribution. The dotted horizontal line is the per-pair budget \(\delta/N\approx10^{-7}\) for \(n=1000\) points and \(\delta=0.05\).
Move the slider to change \(\epsilon\); notice the horizontal axis rescales like \(1/\epsilon^2\).
N_pairs, delta = 1000 * 999 // 2, 0.05
epsilons = [0.1, 0.25, 0.5]
def decay_probabilities(eps):
"""Exact failure probabilities and bounds over a range of k."""
k_max = int(168 / eps**2)
k = np.unique(np.linspace(1, k_max, 400).astype(int))
exact = exact_upper(k, eps) + exact_lower(k, eps)
return dict(
k=k, exact=exact,
chebyshev=np.minimum(1, 2 / (k * eps**2)),
theorem=np.minimum(1, 2 * np.exp(-k * eps**2 / 8)),
k_exact=k[np.argmax(exact <= delta / N_pairs)],
k_theorem=int(np.ceil(8 / eps**2 * np.log(2 * N_pairs / delta))),
k_chebyshev=2 * N_pairs / (eps**2 * delta),
)
decay_data = {eps: decay_probabilities(eps) for eps in epsilons}Plot the failure probabilities and slider
def decay_frame(eps):
data = decay_data[eps]
k = data["k"]
k_max = k[-1]
traces = [
go.Scatter(x=k, y=data["chebyshev"], mode="lines", name="Chebyshev 2/(kε²)",
line=dict(color=INK, width=1.6, dash="dash")),
go.Scatter(x=k, y=data["theorem"], mode="lines",
name="theorem 2e<sup>−kε²/8</sup>", line=dict(color=ORANGE, width=2, dash="dash")),
go.Scatter(x=k, y=data["exact"], mode="lines", name="exact", line=dict(color=BLUE, width=2.4)),
go.Scatter(x=[0, k_max], y=[delta / N_pairs] * 2, mode="lines", name="budget δ/N",
line=dict(color=INK, width=1.2, dash="dot"), hoverinfo="skip"),
]
title = (f"<b>ε = {eps}</b> · budget reached at k ≈ {data['k_exact']} (exact), "
f"k = {data['k_theorem']} (theorem), k = {data['k_chebyshev']:.1e} (Chebyshev)")
return traces, title, k_max
frames_data = {eps: decay_frame(eps) for eps in epsilons}
start = epsilons.index(0.25)
traces, title, k_max = frames_data[epsilons[start]]
fig = go.Figure(traces)
fig.frames = [go.Frame(name=str(eps), data=t, traces=list(range(len(t))),
layout=dict(title=dict(text=tt), xaxis=dict(range=[0, km])))
for eps, (t, tt, km) in frames_data.items()]
style(fig, height=560, title=title, showlegend=True)
fig.update_xaxes(title_text="target dimension k", range=[0, k_max])
fig.update_yaxes(title_text="P(|Z<sub>k</sub> − 1| ≥ ε)", type="log", range=[-15, 0.3],
exponentformat="power")
fig.update_layout(legend=dict(x=0.65, y=0.97), margin=dict(l=70, r=30, t=60, b=130),
sliders=slider(epsilons, start, "ε = "))
fig.show(config=CONFIG)The shape of the tails
Now fix \(k\) and look at how fast each tail falls off as the deviation \(t\) grows. Figure 3 compares the two tails of \(Z_k\) with the tail of a Gaussian with the same mean \(1\) and variance \(2/k\), and with the bound \(e^{-kt^2/8}\) from Theorem 1.
Move the slider to change \(k\).
Plot the tails and slider
def tail_frame(k):
data = tail_data[k]
traces = [
go.Scatter(x=t, y=data["theorem"], mode="lines",
name="theorem e<sup>−kt²/8</sup>", line=dict(color=ORANGE, width=1.8, dash="dash")),
go.Scatter(x=t, y=data["gaussian"], mode="lines",
name="Gaussian, same variance", line=dict(color=INK, width=1.6, dash="dot")),
go.Scatter(x=t, y=data["upper"], mode="lines", name="upper tail P(Z<sub>k</sub> ≥ 1 + t)",
line=dict(color=BLUE, width=2.4)),
go.Scatter(x=t, y=data["lower"], mode="lines", name="lower tail P(Z<sub>k</sub> ≤ 1 − t)",
line=dict(color=TEAL, width=2.4)),
]
return traces, f"<b>k = {k}</b> · standard deviation √(2/k) = {data['sd']:.3f}"
frames_data = {k: tail_frame(k) for k in ks}
start = ks.index(100)
traces, title = frames_data[ks[start]]
fig = go.Figure(traces)
fig.frames = [go.Frame(name=str(k), data=tr, traces=list(range(len(tr))),
layout=dict(title=dict(text=tt)))
for k, (tr, tt) in frames_data.items()]
style(fig, height=560, title=title, showlegend=True)
fig.update_xaxes(title_text="deviation t", range=[0, 1])
fig.update_yaxes(title_text="tail probability", type="log", range=[-16, 0.1], exponentformat="power")
fig.update_layout(legend=dict(x=0.55, y=0.97), margin=dict(l=70, r=30, t=60, b=130),
sliders=slider(ks, start, "k = "))
fig.show(config=CONFIG)A Gaussian tail \(e^{-t^2/(2\cdot2/k)}=e^{-kt^2/4}\) is a downward parabola on a log scale, and for small \(t\) both tails of \(Z_k\) follow it closely. Further out they part ways. The lower tail plunges at \(t=1\), because \(Z_k\geq0\) can never fall below \(1-t\) once \(t>1\). The upper tail is heavier than the Gaussian, because a sum of squares can occasionally be large. The bound \(e^{-kt^2/8}\) is a parabola too, just a shallower one, and it stays above both tails. For \(0<t<1\), Theorem 1 bounds each tail by \(e^{-kt^2/8}\), giving exponential decay in \(k\) for every fixed deviation in this range.
Why this applies to random projections
We now have the concentration tool: for \(0<\epsilon<1\), \(Z_k\) lies outside \([1-\epsilon,1+\epsilon]\) with probability at most \(2e^{-k\epsilon^2/8}\). To make this bound at most \(\delta/N\), it suffices to take \(k\geq\frac8{\epsilon^2}\log\frac{2N}{\delta}\). The dependence on the number of events is logarithmic.
The remaining question is why the distortion of a random projection should have the distribution of \(Z_k\) at all. The next example establishes that connection, then applies the union bound to preserve every pairwise distance.