Frage

I've been scouring the net and documentation to no avail. I can seed random but not the mtrand generator (Mersenne Twister I believe?), no command seems to work.

from pylab import *

# >> seed random number generator <<
print '%.3f' % weibull(2)
print '%.3f' % weibull(2)

I want both of those strings to produce the same result. I am using the function in a more complicated setting, but this should suffice for my purposes.

War es hilfreich?

Lösung

You seed pylab using pylab.seed:

>>> pylab.seed(0)
>>> pylab.weibull(2)
0.89211799004566095
>>> pylab.seed(0)
>>> pylab.weibull(2)
0.89211799004566095
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top