Hacker News new | past | comments | ask | show | jobs | submit login

Well, you can re-flip on >240, with an expected number of flips to receive a number in the range being around 1/(1-15/256) ~ 1.062, so pretty close to just one 8-coin-flip (with some low probability of having to re-flip, which vanishes exponentially as the number of re-flips).

This has the guaranteed correct distribution ('correct' being 'uniform'), too!

EDIT: I guess, to be more clear about the algorithm: flip 8 coins and convert this result to binary. If the result is greater than 240, flip the eight coins again. The number of total 8-coin-flips that need to be done on average is something like 1.062, and the likelihood that you need to perform n 8-coin-flips to receive a result ≤ 240 vanishes exponentially as (15/256)^(-n).

24d10 has a normal-ish distribution. The scheme you suggest will produce a uniform distribution.

Oh, interesting, did not know that! I guess I only now just realized that 24d10 is 10 dice with 24 values (I just read the GGP and thought, oh 240 uniform is easy to make)... there's probably some nice way to emulate that with 1-bit RNGs in expected finite (ideally small!) time.

EDIT: I screwed up again, 24d10 is 24 dice with 10 values. Oops. Point is still roughly the same!

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