Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Darts, Dice, and Coins: Sampling from a Discrete Distribution (2011) (keithschwarz.com)
8 points by davikr 4 months ago | hide | past | favorite | 2 comments


This is good for sampling from a "static" distribution, which has stable p_i parameters, where you can armotize the alias preprocessing step.

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):

https://news.ycombinator.com/item?id=42596716


Ah my domain changed in the meantime, this is the correct URL:

https://terra-incognita.blog/posts/9




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: