문제

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.

도움이 되었습니까?

해결책

You seed pylab using pylab.seed:

>>> pylab.seed(0)
>>> pylab.weibull(2)
0.89211799004566095
>>> pylab.seed(0)
>>> pylab.weibull(2)
0.89211799004566095
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top