Darts, Dice, and Coins: Sampling from a Discrete Distribution (2011)
created: Nov. 17, 2025, 1:53 p.m. | updated: Nov. 23, 2025, 6:57 p.m.
Darts, Dice, and Coins: Sampling from a Discrete Distribution Last Major Update: December 29, 2011 Earlier this year, I asked a question on Stack Overflow about a data structure for loaded dice.
Simulating a Loaded Die with a Fair DieGiven an algorithm for simulating a fair die, can we adapt the algorithm to simulate a loaded die?
The construction is straightforward, elegant, and can easily be generalized to simulate a loaded die using a set of biased coins.
This, if you'll recall, splits the range $[0, 1)$ as follows:Now, let's think about how we might simulate this loaded die using biased coins.
Finally, we simulate rolls of the die by tossing darts randomly at the target, which we can do by a combination of a fair die and biased coins.
3 weeks, 3 days ago: Hacker News