logoalt Hacker News

wilbo • yesterday at 11:22 PM • 1 reply • view on HN

I got lost when OP talked about using 10 integers to choose from 3 choices. I think I figured out what was missing in the explanation.

random_u64() Mod 3 does indeed have a single bucket that is oversized. This overweights one option by about 5×10^-20.

rand() Itself has only 32767 possible values, so it's also common for a bucket to be overweighted depending on the number of buckets.


Replies

incompatible • yesterday at 11:42 PM

Makes you wonder at what point overweighting by about 5×10^-20 is something you'd want to care about.