how to use random bits to simulate a fair 26-sided die?

Posted by Michael Levin on Stack Overflow See other posts from Stack Overflow or by Michael Levin
Published on 2010-05-22T23:24:43Z Indexed on 2010/05/22 23:30 UTC
Read the original article Hit count: 294

How do I use a random number generator that gives bits (0 or 1) to simulate a fair 26-sided die? I want to use a bitstream to pick letters of the English alphabet such that the odds of any one letter coming up is the same as the odds of any other letter (I know real words aren't like that and have specific frequency distributions for each letter but it doesn't matter here). What's the best way to use binary 0/1 decisions to pick letters fairly from the set A-Z? I can think of a few ways to map bits onto letters but it's not obvious to me that they won't be biased. Is there a known good way?

© Stack Overflow or respective owner

Related posts about encoding

Related posts about characters