Subscribe to DSC Newsletter

# Generating Random Points on a Sphere

While this looks like a basic problem, it is actually somewhat more complicated than expected. One might think of generating uniform deviates for the longitude, as well as uniform deviates for the latitude. This will over-sample near the poles and under-sample near the equator: the resulting point distribution won't be uniform on the surface of the sphere. This has serious implications if one wants to measure (say) the average temperature on Earth using (say) 1,000 random locations. If these locations are not random, it will introduce a bias.

How do we fix this problem?

One easy way to produce random points uniformly distributed on a sphere centered at the origin, of radius 1, is to

1. First simulate uniform deviates on the cube [-1, 1] x [-1, 1] x [-1, 1]
2. Discard the points that fall outside the sphere
3. Project all remaining points (those located inside the sphere) on the surface of the sphere

The classic solution is different but produces the same uniform distribution on the sphere:

1. Generate three random numbers (x, y, zusing Gaussian distribution
2. Multiply each number by 1 / SQRT(x^2 + y^2 + z^2)

Note that step #2 in the second algorithm is identical to step #3 in the first algorithm.

Related article

Views: 767

### Replies to This Discussion

does using the following expression give you bias ?

z = sqrt(r^2 - x^2 - y^2),  where x, y are random numbers between [-1, 1].

I just check it with excel with 2 dimension and it seems unioform deviates.

Could you not also, instead of using a Cartesian coordinate system, use a spherical coordinate system?  That way you only have to generate two random variables between 0 and (θ and φ) since r is fixed.

yeah I just tessted with excel. And the pinpoints were not that bad.

I wonder how is it possible to distribute densely near to the poles ??

Alan Ross Groskreutz said:

Could you not also, instead of using a Cartesian coordinate system, use a spherical coordinate system?  That way you only have to generate two random variables between 0 and (θ and φ) since r is fixed.

1

2

3

4

5

6

## Videos

• ### Apache Spark and IBM Streams Working Together in Streaming Analytics

Added by Tim Matteson

• ### Communicating Analytic Insights Visually

Added by Tim Matteson

• Add Videos
• View All

## Top Categories

© 2017   Data Science Central   Powered by