This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: gsl_rand_dir_3d
On Mon, Aug 04, 2003 at 02:38:46PM -0600, James Theiler wrote:
> On Mon, 4 Aug 2003, Stuart O Anderson wrote:
> ] After looking at the algorith a while longer I've begun to suspect it has
> ] a more serious flaw than the s==0 condition. If the Z component is
> ] uniformly distributed (since P(x*x+y*y < s | s<=1 ) = s) and the final
> ] vector's orientation in the X-Y plane is also uniform and independent of Z
> ] then the probability of selecting a final vector with -.5<Z<.5 is equal
> ] to the probability of selecting a final vector with -1<=Z<=-.5 or .5<=Z<=1.
> ] Since the surface area of these two sections is not equal but the
> ] probability of selecting a vector in each section is equal, the
> ] distribution cannot be uniform over the surface of the sphere, since the
> ] probability of selecting a vector in any two regions of equal surface
> ] area must be equal in a uniform distribution.
> Actually, I believe the surface areas of the two regions you describe
> *are* equal. This is at first a little counter-intuitive, but you
> should work it out. The region near the equator seems to have larger
> area because it is farther from the axis, but the region around the
> poles has an extra cosine effect which makes up for this. Hard to
> describe without a picture, but if you try to work it out, I think
> you'll see what I'm talking about.
This is true. A uniform Z from -1 to 1 is okay. I haven't looked
into whether s is uniform, though.
I guess what I posted would be a trig method of figuring it out.
Or, if you *want* the random direction in spherical coordinates, it
is that (without psi). Maybe it could be
gsl_rand_dir_3d_spherical() or something. And/or something closer
to what I posted, gsl_rand_euler() which gives a random orientation
for a solid object.
If someone *really* wants to see it, I could post the math.
--
Jeff Spirko spirko@lehigh.edu spirko@yahoo.com WD3V |=>
The study of non-linear physics is like the study of non-elephant biology.
All theoretical chemistry is really physics;
and all theoretical chemists know it. -- Richard P. Feynman