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.


2 Answers 2


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.

  • 1
    $\begingroup$ In your formula, θ is the colatitude rather than the latitude. $\endgroup$
    – user41837
    Commented Mar 5, 2015 at 15:04

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); 
  • $\begingroup$ Guess samples in direction of the corners of the unit-cube you start with have higher probability. $\endgroup$ Commented Feb 28 at 15:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .