Simple Algorithm
Machine Learning · Convergence · 26 min

The Curse of Dimensionality

Concentrating distances, empty space and minimax rates.

In a thousand dimensions, almost all of a ball's volume lies within 1% of its surface, and every point is nearly the same distance from every other. For learning, the consequence is stark: the best possible error for estimating a β\beta-smooth function decays like n−2β/(2β+d)n^{-2\beta/(2\beta+d)}, so each added dimension multiplies the data you need. Yet real data rarely fill the space they live in, and nearest neighbors adapt to the dimension the data actually have.

What you’ll learn

  • Compute volumes of balls, shells and neighborhoods in high dimension, and explain why local neighborhoods stop being local.
  • Prove that distances concentrate when coordinates are independent, and state the results of Beyer et al. and Aggarwal et al. on relative contrast.
  • Explain hubness: why some points become nearest neighbors of many others in high dimension.
  • State Stone's minimax rate n−2β/(2β+d)n^{-2\beta/(2\beta+d)}, derive the matching k-NN bound for Lipschitz functions and sketch the lower bound.
  • Explain how low intrinsic dimension and other structure let local methods escape the curse.

Empty space

Richard Bellman coined the phrase curse of dimensionality for the exponential growth of a grid with the number of variables. For local learning methods it shows up as geometry. The volume of a ball of radius rr in Rd\R^d is

Vd(r)=πd/2Γ(d/2+1) rd,V_d(r) = \frac{\pi^{d/2}}{\Gamma(d/2 + 1)}\,r^d ,

and three consequences follow.

Dimension ddBall inside the unit cube, Vd(12)V_d(\tfrac12)Cube side holding 1% of uniform data, 0.011/d0.01^{1/d}Mass of the unit ball within 0.01 of its surface, 1−0.99d1 - 0.99^d
20.7850.102.0%
30.5240.223.0%
100.00250.639.6%
1001.9×10−701.9 \times 10^{-70}0.95563%
1000≈0\approx 00.99599.996%
Left: the inscribed ball, the set of points within 12\tfrac12 of the center, holds a vanishing fraction of the cube; almost all of the volume sits in the corners. Middle: a cube-shaped neighborhood must span most of every coordinate's range to hold 1% of the data. Right: in high dimension, almost all of a ball is near its surface.
Predict before you look

In d=100d = 100 dimensions, what fraction of the volume of a ball lies within 1% of its radius from the surface?

Show the answer

63 %

The inner ball of radius 0.99r0.99r has volume 0.99100≈0.3660.99^{100} \approx 0.366 of the whole, so the thin shell holds 1−0.366≈63%1 - 0.366 \approx 63\%. Volume scales like rdr^d, so a 1% change in radius changes volume by about dd percent when dd is small, and swallows nearly everything when dd is large.

The same thinness holds for probability. If x∼N(0,Id)\mathbf x \sim \mathcal N(0, I_d), then E∥x∥2=d\E\norm{\mathbf x}^2 = d and Var⁡∥x∥2=2d\Var\norm{\mathbf x}^2 = 2d, so ∥x∥=d+O(1)\norm{\mathbf x} = \sqrt d + \order{1}: a high-dimensional Gaussian lives in a thin shell of radius d\sqrt d, not near its mode at the origin (Vershynin, 2018, §3.1). And with nn points uniform in the unit ball of Rd\R^d, the median distance from the center to the nearest point is (1−2−1/n)1/d\big(1 - 2^{-1/n}\big)^{1/d}: for n=500n = 500 and d=10d = 10 that is about 0.520.52, more than halfway to the boundary (Hastie, Tibshirani & Friedman, 2009, §2.5). Neighborhoods that hold any data at all are no longer small.

Distances concentrate

Let x\mathbf x and z\mathbf z be independent, each with i.i.d. coordinates, and set Dj=(xj−zj)2D_j = (x_j - z_j)^2 with mean mm and variance vv. The squared distance is a sum of dd i.i.d. terms.

DerivationAll distances look alike
  1. E∥x−z∥2=d m,Var⁡∥x−z∥2=d v\E\norm{\mathbf x - \mathbf z}^2 = d\,m,\qquad \Var\norm{\mathbf x - \mathbf z}^2 = d\,v

    Mean and variance of the squared distance grow linearly in dd:

  2. Var⁡∥x−z∥2E∥x−z∥2=v/m2d⟹∥x−z∥2d m  →  1  in probability\frac{\sqrt{\Var\norm{\mathbf x - \mathbf z}^2}}{\E\norm{\mathbf x - \mathbf z}^2} = \frac{\sqrt{v/m^2}}{\sqrt d}\qquad\Longrightarrow\qquad \frac{\norm{\mathbf x - \mathbf z}^2}{d\,m} \;\to\; 1\ \text{ in probability}

    So the relative spread shrinks like 1/d1/\sqrt d, and Chebyshev's inequality gives concentration around the typical value:

  3. 7/180(1/6)2 d=1.4d\sqrt{\frac{7/180}{(1/6)^2\,d}} = \sqrt{\frac{1.4}{d}}

    For coordinates uniform on [0,1][0,1]: m=E(U−U′)2=16m = \E(U - U')^2 = \tfrac16 and E(U−U′)4=115\E(U - U')^4 = \tfrac1{15}, so v=115−136=7180v = \tfrac1{15} - \tfrac1{36} = \tfrac{7}{180} and the relative spread is 1.4/d\sqrt{1.4/d}: 37% at d=10d = 10, 12% at d=100d = 100, under 4% at d=1000d = 1000.

In a simulation with 1,000 points uniform in the cube and a uniform query, the median farthest-to-nearest ratio was about 70 in 2 dimensions (with large variation), 3.8 in 10, 1.4 in 100 and 1.12 in 1,000. Aggarwal, Hinneburg and Keim (2001) refined the picture for ℓk\ell_k distances with i.i.d. coordinates: the absolute gap E[Dmax⁡−Dmin⁡]\E[D^{\max} - D^{\min}] grows like d1/k−1/2d^{1/k - 1/2}, so it diverges for ℓ1\ell_1, stays bounded for ℓ2\ell_2 and vanishes for ℓk\ell_k with k≥3k \ge 3, while the relative contrast decays like 1/d1/\sqrt d for every kk with a constant that favors small kk. Manhattan distance, and even "fractional" distances with k<1k < 1, kept more contrast in their experiments.

The hypothesis matters as much as the conclusion. Concentration needs many independent coordinates that all contribute, that is, high intrinsic dimension. Clustered data, or data near a low-dimensional set, keep their contrast however many raw features there are; Beyer et al. themselves stressed that their result does not make high-dimensional search meaningless on such workloads.

Hubness. Let Nk(x)N_k(\mathbf x) count how often x\mathbf x appears among the kk nearest neighbors of the other points. Its average is exactly kk, since every point has kk neighbors. Radovanović, Nanopoulos and Ivanović (2010) showed that as the intrinsic dimension grows, the distribution of NkN_k becomes strongly right-skewed: a few hubs appear in very many neighbor lists, and many anti-hubs appear in none. The mechanism is concentration again: points slightly closer than average to the data mean are slightly closer to everyone. In their simulations with i.i.d. uniform data, the (Spearman) correlation between N5N_5 and the distance to the data mean was about −0.02-0.02 in 3 dimensions, −0.80-0.80 in 20 and −0.87-0.87 in 100. Hubs spread their labels to many queries, so a mislabeled hub damages k-NN classification, and retrieval systems return the same items for many unrelated queries.

The statistical curse: minimax rates

Concentration is a geometric statement. The statistical curse is about how much data learning needs. Consider regression, y=f(x)+εy = f(\mathbf x) + \varepsilon with Var⁡ε≤σ2\Var\varepsilon \le \sigma^2 and x\mathbf x in a compact subset of Rd\R^d, and ask for the best worst-case mean squared error over a smoothness class.

DerivationUpper bound: k-NN regression for Lipschitz $f$
  1. E(f^(x)−f(x))2  ≤  σ2k+L2 E ∥X(k)(x)−x∥2\E\big(\hat f(\mathbf x) - f(\mathbf x)\big)^2 \;\le\; \frac{\sigma^2}{k} + L^2\,\E\,\norm{X_{(k)}(\mathbf x) - \mathbf x}^2

    Take β=1\beta = 1: ∣f(x)−f(z)∣≤L∥x−z∥\lvert f(\mathbf x) - f(\mathbf z)\rvert \le L\norm{\mathbf x - \mathbf z}. As in the Descent lesson, the error at x\mathbf x is a variance term plus a squared bias bounded by the distance to the kk-th neighbor:

  2. E∫(f^−f)2 dμ  ≲  σ2k+L2(kn)2/d\E\int\big(\hat f - f\big)^2\,d\mu \;\lesssim\; \frac{\sigma^2}{k} + L^2\Big(\frac kn\Big)^{2/d}

    A ball of radius rr has mass of order rdr^d, so it holds kk of nn points once rd≈k/nr^d \approx k/n. For bounded inputs and d≥3d \ge 3 this gives a squared kk-th neighbor distance of order (k/n)2/d(k/n)^{2/d}, averaged over x\mathbf x (Györfi, Kohler, Krzyżak & Walk, 2002, chapter 6):

  3. k≍n2/(d+2)⟹E∫(f^−f)2 dμ  ≍  n−2/(d+2)k \asymp n^{2/(d+2)} \quad\Longrightarrow\quad \E\int\big(\hat f - f\big)^2\,d\mu \;\asymp\; n^{-2/(d+2)}

    Balance the two terms: k≍n2/(d+2)k \asymp n^{2/(d+2)}, and the error is of order n−2/(d+2)n^{-2/(d+2)}, Stone's rate with β=1\beta = 1. Plain local averaging does not exploit higher smoothness everywhere; local polynomial fits do, and reach n−2β/(2β+d)n^{-2\beta/(2\beta + d)} for larger β\beta.

Lower bound, sketched. Split [0,1]d[0,1]^d into mdm^d small cubes, and place in each a smooth bump of height h≍Lm−βh \asymp L m^{-\beta}, the tallest a β\beta-smooth function can be at that width, with sign ++ or −-. That gives 2md2^{m^d} functions in the class. Each cube receives about n/mdn/m^d observations, and a bump's sign can be detected only if h2⋅n/md≳σ2h^2 \cdot n/m^d \gtrsim \sigma^2. Choosing m2β+d≍nm^{2\beta + d} \asymp n makes every sign a coin flip for any estimator, which then errs by about h2h^2 on a constant fraction of cubes: an error of order m−2β=n−2β/(2β+d)m^{-2\beta} = n^{-2\beta/(2\beta + d)}. Assouad's lemma makes this rigorous (Tsybakov, 2009, chapter 2).

Predict before you look

With β=2\beta = 2 and d=10d = 10, the minimax mean squared error scales like n−4/14n^{-4/14}. By about what factor must nn grow to cut the error tenfold?

Show the answer

3162 ×

n−2/7n^{-2/7} falls tenfold when nn grows by 107/2≈3,16210^{7/2} \approx 3{,}162. In one dimension the same improvement costs a factor of 105/4≈1810^{5/4} \approx 18. Ignoring constants, reaching an error of 0.01 needs about 300 points in one dimension, 10710^7 in ten and 105210^{52} in a hundred.

Escaping the curse

Minimax rates are worst cases over all β\beta-smooth functions on a dd-dimensional set. Real problems are rarely that bad, and nearest neighbors are well placed to exploit it, because they never use the ambient dimension explicitly: only the mass of balls around the query matters.

Low intrinsic dimension. If the data lie on or near a set of dimension d0≪dd_0 \ll d, so that balls around a query have mass of order rd0r^{d_0}, then the kk-th neighbor distance scales like (k/n)1/d0(k/n)^{1/d_0} and the k-NN rates hold with d0d_0 in place of dd. Kpotufe (2011) proved that k-NN regression adapts to the local intrinsic dimension at each query, and that choosing kk locally from the data nearly achieves the minimax rate there, without knowing the dimension. Estimated intrinsic dimensions of natural image datasets are far below their pixel counts, and datasets of lower intrinsic dimension are easier for neural networks to learn (Pope et al., 2021).

StructureWhat replaces dd in the rateTypical methods
Data near a d0d_0-dimensional manifold or setd0d_0k-NN, kernel methods, trees: adaptive automatically
ff depends on ss of the dd featuresss (if the relevant features can be found)feature selection, metric learning
ff is a sum of one-dimensional functions1additive models
ff is a composition of low-dimensional functionsthe effective dimension and smoothness of the hardest piecedeep networks (Schmidt-Hieber, 2020)
Each row is an assumption on the problem, not a free lunch: if it fails, the worst-case rate in dd applies again.
Check your understanding

Images of a rotating object are stored as vectors of 10410^4 pixels, but they are generated by a single rotation angle. What governs how many examples k-NN needs?

  1. The 10410^4 pixel dimensions, since distances are computed in pixel space
  2. Nothing: k-NN cannot work on images
  3. The intrinsic dimension of the image set, here about 1, since ball masses scale with that dimension
  4. The number of classes
Show the answer

C. The intrinsic dimension of the image set, here about 1, since ball masses scale with that dimension

k-NN's rates depend on how fast the mass of a ball around the query grows with its radius. On a one-dimensional curve of images that is like r1r^1, however many pixels each image has. (Whether pixel distance tracks the angle well is a separate question: that is what learned metrics improve.)

Key takeaways

  • High-dimensional space is empty and its volume sits in corners and thin shells: 1−(1−ε)d→11 - (1-\varepsilon)^d \to 1, and neighborhoods holding any data must span most of every coordinate's range.
  • For i.i.d. coordinates, distances concentrate with relative spread O(1/d)\order{1/\sqrt d}, so the farthest and nearest neighbors become nearly equidistant (Beyer et al.); concentration requires high intrinsic dimension.
  • Hubness: in high intrinsic dimension a few points become neighbors of many others, typically those closest to the data mean.
  • The minimax mean squared error for β\beta-smooth regression is of order n−2β/(2β+d)n^{-2\beta/(2\beta+d)} (Stone, 1982); k-NN attains n−2/(d+2)n^{-2/(d+2)} for Lipschitz functions with k≍n2/(d+2)k \asymp n^{2/(d+2)}.
  • Local methods escape the curse when the data have low intrinsic dimension: k-NN adapts to the local intrinsic dimension automatically (Kpotufe, 2011).

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

In d=500d = 500, roughly what fraction of a ball's volume lies within 1% of its radius from the surface?

  1. About 1%
  2. About 5%
  3. About 63%
  4. Over 99%
Show the answer

D. Over 99%

1−0.99500=1−e500ln⁡0.99≈1−e−5.03≈0.9931 - 0.99^{500} = 1 - e^{500\ln 0.99} \approx 1 - e^{-5.03} \approx 0.993. Volume scales as rdr^d, so for large dd nearly all of it sits next to the surface.

Question 2

Points have i.i.d. coordinates. With the number of points fixed, what happens to the ratio of the farthest to the nearest distance from a query as the dimension grows?

  1. It tends to 1, because every distance concentrates around the same typical value
  2. It grows without bound, because space gets bigger
  3. It stays constant, because both distances scale like d\sqrt d
  4. It tends to 0
Show the answer

A. It tends to 1, because every distance concentrates around the same typical value

Each squared distance is a sum of dd i.i.d. terms, so its relative fluctuation shrinks like 1/d1/\sqrt d. Both the largest and the smallest of finitely many such distances are dm (1+o(1))\sqrt{dm}\,(1 + o(1)), so their ratio approaches 1.

Question 3

For a Lipschitz regression function (β=1\beta = 1) in d=8d = 8 dimensions, how does the best achievable mean squared error scale with nn?

  1. n−1n^{-1}
  2. n−1/2n^{-1/2}
  3. n−1/5n^{-1/5}
  4. n−1/8n^{-1/8}
Show the answer

C. n−1/5n^{-1/5}

n−2β/(2β+d)=n−2/10=n−1/5n^{-2\beta/(2\beta + d)} = n^{-2/10} = n^{-1/5}. Halving the error takes 25=322^5 = 32 times as much data. k-NN with k≍n2/(d+2)=n1/5k \asymp n^{2/(d+2)} = n^{1/5} achieves it.

Question 4

In high-dimensional data with i.i.d. coordinates, which points tend to become hubs, appearing in many other points' nearest-neighbor lists?

  1. Outliers far from the data
  2. Points close to the data mean, which are slightly closer than average to everyone
  3. Points chosen at random, with no pattern
  4. Only duplicated points
Show the answer

B. Points close to the data mean, which are slightly closer than average to everyone

Distances to the mean concentrate but keep some spread. A point slightly nearer the mean is, on average, slightly nearer to all other points, and when every distance is almost equal that small edge puts it into many neighbor lists. Radovanović et al. measured a correlation of about −0.87-0.87 between N5N_5 and the distance to the mean for uniform data in 100 dimensions.

Further reading

  • K. Beyer, J. Goldstein, R. Ramakrishnan & U. Shaft, "When is 'nearest neighbor' meaningful?" Database Theory — ICDT'99, LNCS 1540, 217–235 (1999).
  • C. J. Stone, "Optimal global rates of convergence for nonparametric regression," Annals of Statistics 10(4), 1040–1053 (1982).
  • S. Kpotufe, "k-NN regression adapts to local intrinsic dimension," Advances in Neural Information Processing Systems 24 (2011).
  • C. C. Aggarwal, A. Hinneburg & D. A. Keim, "On the surprising behavior of distance metrics in high dimensional space," Database Theory — ICDT 2001, LNCS 1973, 420–434 (2001).
  • M. Radovanović, A. Nanopoulos & M. Ivanović, "Hubs in space: popular nearest neighbors in high-dimensional data," Journal of Machine Learning Research 11, 2487–2531 (2010).