[Numpy-discussion] Random number generators.

Robert Kern robert.kern at gmail.com
Sun Jun 4 18:04:13 EDT 2006


Charles R Harris wrote:
> For generating large
> arrays of random numbers on 64 bit architectures it looks like MWC8222
> is a winner. So, the question is, is there a good way to make the rng
> selectable?

Sure! All of the distributions ultimately depend on the uniform generators
(rk_random, rk_double, etc.). It would be possible to alter the rk_state struct
to store data for multiple generators (probably through a union) and store
function pointers to the uniform generators. The public API rk_random,
rk_double, etc. would be modified to call the function pointers to the private
API functions depending on the actual generator chosen.

At the Pyrex level, some modifications would need to be made to the RandomState
constructor (or we would need to make alternate constructors) and the seeding
methods. Nothing too bad. I don't think it would be worthwhile to change the
numpy.random.* functions that alias the methods on the default RandomState
object. Code that needs customizable PRNGs should be taking a RandomState object
instead of relying on the function-alike aliases.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco





More information about the NumPy-Discussion mailing list