top | item 43312968

(no title)

aqrit | 11 months 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 would also move the multiply --or divide by constant-- out of the loop.

discuss

order

fanf2|11 months ago

Lemire’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.