Wikipedia:Reference desk/Archives/Mathematics/2014 March 26

Mathematics desk
< March 25 << Feb | March | Apr >> March 27 >
Welcome to the Wikipedia Mathematics Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


March 26

edit

Distribution of points on a sphere

edit

I've been using this algorithm for coming up with a uniform distribution of points on an n-sphere (Python notation):

X = [random.gauss(0, 1) for i in range(n)]
t = math.sqrt(sum([i**2 for i in X]))
Y = [X[i] / t for i in range(n)]
return Y

Does the resulting Y distribution have a name, or can a closed form be derived for it? 70.190.182.236 (talk) 20:39, 26 March 2014 (UTC)[reply]

This is the unique rotationally-invariant probability measure on the sphere. I'm not sure it has a name as such, but it can be obtained as a symmetry reduction of the Haar measure on the group of rotations SO(n). The fact that your probability distribution has this property follows from the fact that if   are iid (standard) Gaussian random variables, then the n-dimensional random variable   is normally distributed with pdf  , which is rotationally invariant. Sławomir Biały (talk) 21:02, 26 March 2014 (UTC)[reply]
Note that this topic was discussed here before (although not specifically what to name the method you describe): See Wikipedia:Reference_desk/Archives/Mathematics/2007_August_29#Distributing_points_on_a_sphere and Wikipedia:Reference_desk/Archives/Mathematics/2010_April_30#Even_distribution_on_a_sphere. StuRat (talk) 21:16, 26 March 2014 (UTC)[reply]
I think those are about optimally distributing multiple points on a sphere, whereas the OP is asking about the probability distribution of a single point chosen "uniformly at random" on a sphere. Sławomir Biały (talk) 21:20, 26 March 2014 (UTC)[reply]
That's a very nice algorithm, thanks very much 70.190.182.236 and Sławomir. Dmcq (talk) 15:28, 27 March 2014 (UTC)[reply]
There might be a slight bias to the output due to limits of machine floating point operations. I'm not really an expert on such things, but I think it would be prudent to drop the cases where the norm t is either very small or very large. Sławomir Biały (talk) 17:08, 27 March 2014 (UTC)[reply]
I formatted the code for easier reading; I hope you don't mind. By the way I'd use
Y = [x/t for x in X];
no need for range there. —Tamfang (talk) 07:27, 28 March 2014 (UTC)[reply]
See also b:Mathematica/Uniform_Spherical_Distribution, which seems as sensible a name as any; it also gives explicit formulas in terms of θ and φ. --Tardis (talk) 08:46, 30 March 2014 (UTC)[reply]
phi := 2 ArcSin[Sqrt[Random[]]] (for colatitude) is weird, with an unnecessary sqrt; I don't understand the voodoo that got there (being unacquainted with Jacobians), and haven't worked out whether it matches the formula that I've always used: arcsin(1-2*random()), if the output of random() is between 0 and 1 – an application of Archimedes' theorem that the area between two planes both perpendicular to the axis of a cylinder is the same on the cylinder as on an inscribed sphere (if each plane cuts the sphere in at least one point). —Tamfang (talk) 04:50, 31 March 2014 (UTC)[reply]