[Top][All Lists]

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

Re: [Bug-gsl] Performance of gsl_rng_uniform_int()

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

Brian Gough <address@hidden> writes:

> Markus Armbruster writes:
>  > 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?
> The distribution is technically not uniform if the range of r is not a
> multiple of n.

Hmm.  You're right, because floating-point numbers are not real
numbers.  The difference matters when n is large.  I guess I can use
the faster method for throwing six-sided dice :)

reply via email to

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