[Numpy-discussion] Is there anyway to seed random numbers without global state?

Gael Varoquaux gael.varoquaux at normalesup.org
Mon Jan 12 14:52:01 EST 2009


On Mon, Jan 12, 2009 at 01:41:24PM -0600, Tom Denniston wrote:
> I would think the ideal would be to be able to build random number
> objects where each has a seed so that each object's seed is
> independent.

You mean something like:

In [1]: import numpy as np

In [2]: rs = np.random.RandomState(seed=3)
 
In [3]: rs.rand()
Out[3]: 0.12671989922202853

:)

Gaël



More information about the NumPy-Discussion mailing list