没有,要么设置种子或状态就足够了:
import random
# set seed and get state
random.seed(0)
orig_state = random.getstate()
print random.random()
# 0.8444218515250481
# change the RNG seed
random.seed(1)
print random.random()
# 0.13436424411240122
# setting the seed back to 0 resets the RNG back to the original state
random.seed(0)
new_state = random.getstate()
assert new_state == orig_state
# since the state of the RNG is the same as before, it will produce the same
# sequence of pseudorandom output
print random.random()
# 0.8444218515250481
# we could also achieve the same outcome by resetting the state explicitly
random.setstate(orig_state)
print random.random()
# 0.8444218515250481
设置种子通常更方便比显式设置RNG状态做编程。
伪随机数生成器将始终表现确定性,无论您设置种子还是状态 –
如果考虑到伪随机性,是的。但是,对于使用不可观测和不可预测的变量作为种子的用户(例如,以毫秒为单位的时间)意味着结果是意外的。这就是我的非确定性意思。 – hajtos