[Numpy-discussion] Numpy random: independent streams

Robert Kern robert.kern at gmail.com
Wed Aug 6 05:32:04 EDT 2008


On Wed, Aug 6, 2008 at 04:30, Ludwig <ludwigbrinckmann at gmail.com> wrote:
> The Python standard random API allows me to define multiple independent
> random streams, which I can control with their own seed, e.g.
>
> import random
> generator_1 = random.Random()
> generator_2 = random.Random()
>
> generator_1.seed(100)
> generator_2.seed(100)
>
> So now generator_1 and 2 will produce the same sequence.
>
> Is there an equivalent for this in numpy? (Apart from, as it seems, the
> oldnumeric package http://numpy.scipy.org/numpydoc/numpy-20.html)?

from numpy import random
generator_1 = random.RandomState(100)
generator_2 = random.RandomState(100)

-- 
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