Random – How to Pick a Random Point on the Surface of a Sphere with Equal Distribution

randomspherical coordinates

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.

Best Answer

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.