You might want to take a look at http://en.m.wikipedia.org/wiki/Alias_method
There's a nice, detailed exposition at http://www.keithschwarz.com/darts-dice-coins/
You might want to take a look at http://en.m.wikipedia.org/wiki/Alias_method
There's a nice, detailed exposition at http://www.keithschwarz.com/darts-dice-coins/