How can I pick a random point on the surface of a sphere with equal distribution?

I've got a random number generator that yields values between 0 and 1, and I'd like to use it to select a random point on the surface of a sphere where all points on the sphere are equally likely.

Selecting the longitude is easy as all lines of longitude are of equal length. x × 360°.

Latitude, on the other hand, requires that 0° (the equator) is twice as likely to be selected than 60°. 90° would have an almost zero chance of being selected.


As you point out, the area element on the sphere depends on latitude. If $u,v$ are uniformly distributed in $[0,1]$, then $$\begin{align*} \phi &= 2\pi u \\\\ \theta &= \cos^{-1}(2v-1) \end{align*}$$ are uniformly distributed over the sphere. Here $\theta$ represents latitude and $\phi$ longitude, both in radians. For further details, more methods and some Mathematica code, see Sphere Point Picking at MathWorld.


Pick a fixed number of samples from your uniform distribution, say 15, center them (ie: subtract .5) and add them together. This will generate a 1D normally distributed variable, due to the central limit theorem.

Now do this three times to get three 1D normally distributed random variables, and use one for each coordinate in a vector. This will yield a single 3D normally distributed vector, due to the properties of normal distributions.

Now divide the vector by it's length to normalize it. This will result in a uniformly distributed random vector on the sphere due to the fact that normal distributions are radially symmetric.

Matlabish code:

xx = rand(1,15) - .5;
yy = rand(1,15) - .5;
zz = rand(1,15) - .5;

x=sum(xx); y=sum(yy); z=sum(zz);
v = [x y z]./norm([x y z],2);