TOPICS
Search

Sphere Point Picking


SphericalDistribution

To pick a random point on the surface of a unit sphere, it is incorrect to select spherical coordinates theta and phi from uniform distributions theta in [0,2pi) and phi in [0,pi], since the area element dOmega=sinphidthetadphi is a function of phi, and hence points picked in this way will be "bunched" near the poles (left figure above).

n random points can be picked on a unit sphere in the Wolfram Language using the function RandomPoint[Sphere[], n].

To obtain points such that any small area on the sphere is expected to contain the same number of points (right figure above), choose U and V to be random variates on (0,1). Then

theta=2piu
(1)
phi=cos^(-1)(2v-1)
(2)

gives the spherical coordinates for a set of points which are uniformly distributed over S^2. This works since the differential element of solid angle is given by

 dOmega=sinphidthetadphi=-dthetad(cosphi).
(3)

The distribution P_phi of polar angles can be found from

 P_phidphi=P_v|(dv)/(dphi)|dphi,
(4)

by taking the derivative of (2) with respect to v to get dphi/dv, solving (2) for v, and plugging the results back in to (4) with P_v=1 to obtain the distribution

 P_phi=1/2sinphi.
(5)
SpherePointPickingUTheta

Similarly, we can pick u=cosphi to be uniformly distributed (so we have du=sinphidphi) and obtain the points

x=sqrt(1-u^2)costheta
(6)
y=sqrt(1-u^2)sintheta
(7)
z=u,
(8)

with theta in [0,2pi) and u in [-1,1], which are also uniformly distributed over S^2.

SpherePointPickingMarsaglia

Marsaglia (1972) derived an elegant method that consists of picking x_1 and x_2 from independent uniform distributions on (-1,1) and rejecting points for which x_1^2+x_2^2>=1. From the remaining points,

x=2x_1sqrt(1-x_1^2-x_2^2)
(9)
y=2x_2sqrt(1-x_1^2-x_2^2)
(10)
z=1-2(x_1^2+x_2^2)
(11)

have a uniform distribution on the surface of a unit sphere. This method can also be extended to hypersphere point picking. The plots above show the distribution of points for 100, 1000, and 5000 initial points (where the counts refer to the number of points before throwing away).

SpherePointPickingCook

Cook (1957) extended a method of von Neumann (1951) to give a simple method of picking points uniformly distributed on the surface of a unit sphere. Pick four numbers x_0, x_1, x_2, and x_3 from a uniform distribution on (-1,1), and reject pairs with

 x_0^2+x_1^2+x_2^2+x_3^2>=1.
(12)

From the remaining points, the rules of quaternion transformation then imply that the points with Cartesian coordinates

x=(2(x_1x_3+x_0x_2))/(x_0^2+x_1^2+x_2^2+x_3^2)
(13)
y=(2(x_2x_3-x_0x_1))/(x_0^2+x_1^2+x_2^2+x_3^2)
(14)
z=(x_0^2+x_3^2-x_1^2-x_2^2)/(x_0^2+x_1^2+x_2^2+x_3^2)
(15)

have the desired distribution (Cook 1957, Marsaglia 1972). The plots above show the distribution of points for 100, 1000, and 5000 initial points (where the counts refers to the number of points before throwing away).

Another easy way to pick a random point on a sphere is to generate three Gaussian random variables x, y, and z. Then the distribution of the vectors

 1/(sqrt(x^2+y^2+z^2))[x; y; z]
(16)

is uniform over the surface S^2 (Muller 1959, Marsaglia 1972).


See also

Ball Triangle Picking, Circle Point Picking, Disk Point Picking, Great Circle, Hypersphere Point Picking, Noise Sphere, Sphere Line Picking, Sphere Tetrahedron Picking, Thomson Problem

Explore with Wolfram|Alpha

References

Cook, J. M. "Technical Notes and Short Papers: Rational Formulae for the Production of a Spherically Symmetric Probability Distribution." Math. Tables Aids Comput. 11, 81-82, 1957.Feller, W. An Introduction to Probability Theory and Its Applications, Vol. 2, 3rd ed. New York: Wiley, 1971.Knuth, D. E. The Art of Computer Programming, Vol. 2: Seminumerical Algorithms, 3rd ed. Reading, MA: Addison-Wesley, pp. 130-131, 1998.Marsaglia, G. "Choosing a Point from the Surface of a Sphere." Ann. Math. Stat. 43, 645-646, 1972.Muller, M. E. "A Note on a Method for Generating Points Uniformly on N-Dimensional Spheres." Comm. Assoc. Comput. Mach. 2, 19-20, Apr. 1959.Rusin, D. "N-Dim Spherical Random Number Drawing." In The Mathematical Atlas. http://www.math.niu.edu/~rusin/known-math/96/sph.rand.Salamin, G. "Re: Random Points on a Sphere." math-fun@cs.arizona.edu posting, May 5, 1997.Stephens, M. A. "The Testing of Unit Vectors for Randomness." J. Amer. Stat. Assoc. 59, 160-167, 1964.von Neumann, J. "Various Techniques Used in Connection with Random Digits." NBS Appl. Math. Ser., No. 12. Washington, DC: U.S. Government Printing Office, pp. 36-38, 1951.Watson, G. S. and Williams, E. J. "On the Construction of Significance Tests on the Circle and Sphere." Biometrika 43, 344-352, 1956.

Referenced on Wolfram|Alpha

Sphere Point Picking

Cite this as:

Weisstein, Eric W. "Sphere Point Picking." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/SpherePointPicking.html

Subject classifications