26 January 2009

Probabilistic fun with the n-sphere

On reddit: a link to the old chestnut that high-dimensional spheres are weird. If you consider the volume of the unit ball in Rn as a function of n, it increases up to n=5 and then decreases. The volume is πn/2/((n/2)!). (By the way, I generally use the factorial notation, not the Γ notation, even when the argument isn't an integer.)

But I hear you complaining that it doesn't make sense to compare volumes in different dimensions! Fair enough. Compare the volume of the unit ball in Rn to the cube circumscribing it, which has volume 2n. Then the portion of the cube which is inside the ball is f(n) = πn/2/((n/2)! 2n). This is rapidly decreasing with n. For n = 2, it's π/4 -- the volume of the unit disc is π, and it can be inscribed in a square of area 4. In n = 3, the unit ball has volume 4π/3 and it's inscribed in a cube of size 8, so we get f(3) = π/6. But f(n) decreases superexponentially. f(10) is about 0.0025, f(20) is about 25 in a billion.

I was surprised that it decayed that quickly -- I'd never bothered to work it out. But if you think about it probabilistically, it kind of makes sense. Namely, a random point in the unit n-cube can be identified with its coordinates (x1, x2, ..., xn). It's in the unit n-sphere if and only if the sum of the squares of those coordinates is less than 1. Let yi = xi2 -- then yi has mean 1/3 and variance 4/45. (That's calculus.) So the sum of the squares of the coordinates is a sum of n such independent random variables, and is thus itself a random variable with mean n/3 and variance 4n/45 -- it's no surprise most of its mass is at n > 1. One could probably use large deviation inequalities to quantify this, but come on, it's 11 at night and I have real work to do.