gpt4 book ai didi

python - 我应该播种随机数生成器吗?

转载 作者:行者123 更新时间:2023-11-28 19:33:26 25 4
gpt4 key购买 nike

From the docs:

random.seed(a=None, version=2) Initialize the random number generator.

If a is omitted or None, the current system time is used. If randomness sources are provided by the operating system, they are used instead of the system time (see the os.urandom() function for details on availability).

但是...如果它真的是随机的...(我想我读到它使用的是 Mersenne,所以它非常随机)...播种它有什么意义?无论哪种方式,结果都是不可预测的……对吗?

最佳答案

如果您希望每次运行都使用不同的随机数,则默认值可能是最好的。如果出于某种原因您需要可重复随机数,例如在测试中,使用种子。

关于python - 我应该播种随机数生成器吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19166784/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com