Seed Pylab's random number generator?
-
18-06-2021 - |
Pregunta
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.
Solución
You seed pylab using pylab.seed
:
>>> pylab.seed(0)
>>> pylab.weibull(2)
0.89211799004566095
>>> pylab.seed(0)
>>> pylab.weibull(2)
0.89211799004566095
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow