Probability – How to Generate Equiprobable Numbers with a Random Generator

combinatoricselementary-number-theoryprobabilityrandom

Is it possible to emulate a 2 sided coin flip (50/50) with a random number generator which outputs equiprobably the numbers 1, 2 and 3 ?
If yes, how ?

If not why ?

Is there a theorem?

Can it be expanded to any numbers x ("sides" of the coin) and y (random generator output) ?

Best Answer

Yes, of course. The simplest way to do this is to treat $1$ as heads, $2$ as tails, and try again if you get a $3$.

The same approach works whenever $y>x$. If $y<x$, choose $n$ large enough that $y^n>x$, then generate $n$ numbers at a time and use the above approach with the resulting $n$-tuples.

Related Question