My mistake here; you do need sqrt to normalize, but that's not a big deal. But it's not restricted to any particular dimension. -- Gene
________________________________ From: Dan Asimov <dasimov@earthlink.net> To: Eugene Salamin <gene_salamin@yahoo.com>; math-fun <math-fun@mailman.xmission.com> Sent: Subject: Re: [math-fun] Gary Antonick is edging away from the following bonus puzzle
And what Gene mentions is far better than the obvious "rejection method" I used as a green programmer: keep picking sets of n+1 points at random in [-1,1] until the sum S of their squares is in (0,1] then normalize the point in R^(n+1) to the sphere.
But the fraction of sets that will be accepted decreases faster than 1/(n/2)!, so this method quickly fails to be practical as n gets big. For n = 10 the fraction is less than 1 in 50 million.
--Dan (Begun before Fred's post on the rejection method in R^4.)
On Jul 5, 2014, at 8:55 AM, Eugene Salamin via math-fun <math-fun@mailman.xmission.com> wrote:
Random points on the unit n-sphere can be generated without the need for sqrt and trig. Generate n+1 independent Gaussian random numbers, and normalize the vector to unit length.