Sunday, November 13, 2011

pick a random point on the surface of a unit sphere;mathematica

DOWNLOAD Mathematica Notebook
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).
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).
Weisstein, Eric W. "Sphere Point Picking." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/SpherePointPicking.html

No comments:

Post a Comment