4 ms·
> “regular” rejection sampling I was thinking naive: mask off unwanted bits then reject any value above the limit. It would seem like https://c-faq.com/lib/ra
by aqrit 2y ago
> “regular” rejection sampling
I was thinking naive: mask off unwanted bits then reject any value above the limit.
It would seem like https://c-faq.com/lib/randrange.html https://c-faq.com/lib/randrange.html would also move the multiply --or divide by constant-- out of the loop.
- fanf2 2y agoLemire’s algorithm rejects the fewest possible samples from the random number generator, so it’s generally the fastest. The multiplication costs very little compared to the RNG.