[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gsl] Performance of gsl_rng_uniform_int()

From: Markus Armbruster
Subject: [Bug-gsl] Performance of gsl_rng_uniform_int()
Date: Sun, 13 Feb 2005 14:36:37 +0100
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

I remember enough math to be adequately cautious with PRNGs.  I may
overlook something deep, but isn't

   (unsigned long)(gsl_rng_uniform (r) * n)

a perfectly fine way to get uniformely distributed integers from 0 to
n-1 inclusive?

In my experience, that's faster than gsl_rng_uniform_int (r, n) for
many random number generators in GSL.  On my machine, this includes
important ones like ranlxs0 (~50% in my simple benchmark), ranlxs1
(~25%), ranlxs2 (~14%), ranlxd1 (15%), ranlxd2 (~9%), and even taus

I realize relative speed of integer and floating-point depends on the
machine.  But generators like ranlxs0 rely on the design assumption
that floating-point is fast.  Would it make sense to use such an
alternative implementation of gsl_rng_uniform_int() with such

reply via email to

[Prev in Thread] Current Thread [Next in Thread]