python random.shuffle的随机性

标签 python random shuffle

以下来自python网站,关于

random.shuffle(x[, random])

Shuffle the sequence x in place. The optional argument random is a 0-argument function returning a random float in [0.0, 1.0); by default, this is the function random().

Note that for even rather small len(x), the total number of permutations of x is larger than the period of most random number generators; this implies that most permutations of a long sequence can never be generated.

如果我想重复获取 ['a'..'k'] 的随机排列,似乎 shuffle 不会给我随机性。我的理解对吗?

谢谢!

最佳答案

You don't have anything to worry about.虽然 len(x) 低于 2000,但 random.shuffle 应该可以正常工作。

关于python random.shuffle的随机性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3160214/

相关文章:

python - Django 向装饰器添加可选参数

python - 在 Python 中重复捕获奇怪的结果

python - numpy 库的“包含”?

java - 随机数学生成算法不起作用

python - 单类机争夺计划

python - 您将如何向 Pandas 数据框添加时间戳列?

java - 这两种查找随机数的方法之间的区别?

linux - 我可以在没有硬件生成器的情况下使用 rng-daemon 来增加 linux 熵吗?

PHP CSS Color Shuffle 数组?

python - Numpy:使用不同的种子多次统一洗牌数组