n points are drawn uniformly in the unit ball in p dimensions. Show that the median distance from the origin to the nearest point is d=(1−(12)1/n)1/p. What is its value for n=500 with p=2 and p=10, and what does it mean for k-NN?

Supervised learning, k-nearest neighbours
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can turn "volume scales as rp" into a distribution for the nearest neighbour distance.

Key idea

The chance a point lies within radius r is rp, so P(nearest>r)=(1−rp)n; set it to 12.

Steps

  1. The ball of radius r has a fraction rp of the volume of the unit ball. So one random point falls within r with probability rp.
  2. All n points must fall outside for the nearest distance to exceed r. They are independent, so P(nearest>r)=(1−rp)n.
  3. Median: (1−dp)n=12, so dp=1−(12)1/n, and d=(1−(12)1/n)1/p.
  4. With n=500: (12)1/500=e−ln⁡2/500≈0.998615, so 1−…≈0.001385.
  5. For p=2: d=0.001385≈0.037. The nearest point is very close.
  6. For p=10: d=0.0013850.1=e0.1ln⁡0.001385=e−0.658≈0.518. The nearest neighbour is more than half-way to the edge of the ball, even with 500 points.
  7. Meaning: in high dimensions, "nearest" neighbours are not near. The k-NN assumption that nearby points share a label fails, so k-NN bias grows. You need n exponentially large in p to keep the neighbourhood small.

Common mistakes

How long your answer should be

Half a page; 5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Supervised learning: A Gaussian naive Bayes classifier has two classes. Class A has prior 0.6, feature means (1,2) and feature variances (1,4). Class B has prior 0.4, means (3,0) and variances (1,1). Which class is the point x=(2,1) assigned to?
Next in Supervised learning: Multiple discriminant analysis (multi-class Fisher LDA) solves SBv=λSWv. For C=3 classes in d=100 dimensions with n=60 training points, how many useful discriminant directions are there, and what goes wrong with SW? How can you fix it?