When random is not actually random enough
发生了什么
There is a common pattern you see pop up in codebases everywhere that many of us have written: given a set of objects, pick one at random. Every object should have the same chance of being picked. A rather simple and direct solution is to pick a big random number, then clamp that number to the number of choices by modulo:
摘要按规则整理自下方来源原文
为什么在扩散
时间线
- Hacker News 最先出现Hacker News
- Lobsters 出现讨论Lobsters