Darts, Dice, and Coins: Sampling from a Discrete Distribution (2011)
keithschwarz.com
keithschwarz.com
If you have a distribution that changes from time to time, for example LLMs where you have a new discrete distribution for every step (N-dimensional dice roll), other methods are used. Recently I wrote a writeup comparing three methods (spoilers: simple is best):