random.shuffle() 是否使用均匀分布?
Does random.shuffle() uses uniform distribution?
我在我的代码中使用以下混洗算法来混洗列表。但我想知道在 random.shuffle()
.
中假设了什么样的分布
import random
random.shuffle(x)
其中 x
是一个列表。
我在某处读到随机函数通常使用均匀分布,但我在 random.shuffle
的随机函数页面上找不到任何明确的信息
有人知道吗?
约翰·科尔曼写道:
It uses the Fisher-Yates shuffle. Whether or not this is explicitly said in the documentation, it is both the obvious choice and clearly implemented in the source
我在我的代码中使用以下混洗算法来混洗列表。但我想知道在 random.shuffle()
.
import random
random.shuffle(x)
其中 x
是一个列表。
我在某处读到随机函数通常使用均匀分布,但我在 random.shuffle
的随机函数页面上找不到任何明确的信息有人知道吗?
约翰·科尔曼写道:
It uses the Fisher-Yates shuffle. Whether or not this is explicitly said in the documentation, it is both the obvious choice and clearly implemented in the source