Sign up ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|cite|improve this question

2 Answers 2

up vote 16 down vote accepted

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.

share|cite|improve this answer
In your formula, θ is the colatitude rather than the latitude. – Tos Mar 5 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); 
share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.