circular random number distribution
Jochen Küpper
jochen@fhi-berlin.mpg.de
Tue Aug 9 10:33:00 GMT 2005
Ok, I did some quick tests, the times are for the creation of 1e5 xy
pairs plus some constant cruft done in all runs -- runtime is always
3.4s (+-0.5) for all approaches.... (This is not a good benchmark(!),
it's only meant to give me an idea of what is going on.)
I tried:
rejection,
trigonomtric without sqrt,
trigonomtrix + sqrt,
gsl_ran_dir_2d + sqrt,
gsl_ran_dir_2d_trig_method + sqrt.
"Robert G. Brown" <rgb@phy.duke.edu> writes:
>> | phi = gsl_ran_flat(rng, 0, 2.0*PI);
>> | r = gsl_ran_flat(rng, 0, 1);
>> | x = sqrt(r)*cos(phi);
>> | y = sqrt(r)*sin(phi);
> I'm probably late with this (sorry, busy weekend) but: Your
> accept-reject method is almost certainly much faster than using
> ANYTHING with transcendental calls in it.
Well, I am told that some machines (i.e. PCs) have these functions in
hardware.
> In fact, your sqrt call is redundant
Well, that's the deal: It isn't!
Without the sqrt, the functions are peaked at the center. With the
sqrt they are uniform.
I guess I am going with the reject anyway... Thanks for everybodies
suggestions and help.
Greetings,
Jochen
--
Einigkeit und Recht und Freiheit http://www.Jochen-Kuepper.de
Liberté, Égalité, Fraternité GnuPG key: CC1B0B4D
(Part 3 you find in my messages before fall 2003.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gsl-discuss/attachments/20050809/fc4244ac/attachment.sig>
More information about the Gsl-discuss
mailing list