# Choosing point uniformly on surface of sphere

I saw the following statement posted by Fermat's Library on Twitter:

The way to correctly generate a random point on the surface of a unit sphere is not to pick uniform distributions $$\theta$$ in $$[0,2\pi)$$ and $$\phi$$ in $$[0,\pi)$$.

Instead, choose $$u$$ and $$v$$ from uniform distributions on $$[0,1)$$. Then,

• $$\phi = \cos^{-1}(2v-1)$$
• $$\theta = 2\pi u$$

I can see why uniformly choosing $$\theta$$ in $$[0,2\pi)$$ and $$\phi$$ in $$[0,\pi)$$ would lead to points near the poles being more likely to be chosen than points near the equator.

But I can't think of an intuitive explanation for why the given solution correctly gives a uniform distribution. Is there a good intuitive explanation for this?

• it's the famous theorem of Archimedes saying that the projection of a sphere to a tangent cylinder preserves the area (a small piece of the sphere gets stretched in one direction and squeezed in the orthogonal direction, by the same amount). Dec 19, 2020 at 7:26

The length of the ring at latitude $$\phi$$ is proportional to $$\cos\phi$$; this is also proportional to the pdf of the random variable that is the latitude of a point uniformly distributed on a sphere.
The integral of the pdf is the cdf; since the pdf expression contains $$\cos\phi$$ its integral should also be a sine wave. If we use the angular difference from a pole as variable, this wave should go from $$0$$ at $$0$$ to $$1$$ at $$\pi$$.
The inverse of the cdf is the quantile function, which is what we really want. Since the cdf was a sine wave, the quantile function should be the $$\cos^{-1}$$ or $$\sin^{-1}$$ of something; looking at the required values ($$0$$ at $$0$$, $$\pi$$ at $$1$$) we infer that the quantile function is $$\cos^{-1}(1-2x)$$. To generate the latitude for a uniform random point on the sphere, $$x$$ should be a uniform $$U(0,1)$$ variate; it is easy to see that both $$1-2x$$ and $$2x-1$$ are uniformly distributed over $$[-1,1]$$, so we have $$\phi=\cos^{-1}(2x-1)$$.