Probability of $0.55$ for a fair coin Imagine we have a fair coin that comes with probability of $0.5$ for  head. Is it possible that this coin makes a probability of $0.55$? What about $\frac{1}{3}$ ?
 A: Write the probability $p$ you want to simulate as a binary decimal, e.g. $0.55=0.100011\ldots$ (from $0.55={1\over2}+{1\over32}+{1\over64}+\cdots$) or ${1\over3}=0.010101\ldots$. Then toss your fair coin repeatedly, recording the string of Heads and Tails as a binary decimal, with Heads as $1$ and Tails as $0$. Continue doing so until the string departs from the binary decimal for $p$. If the departure is less than $p$, consider it a win, if more than $p$, a loss.
Interestingly, the average number of tosses required is always $2$, regardless of the value for $p$.
This algorithm, which I by no means invented (I do not remember where I first came across it), takes some getting used to. For one thing, the simulation terminates half the time after a single toss of the fair coin, which seems counterintuitive. One way to understand why it works is to imagine you have a friend who continues to toss the fair coin ad infinitum, adding to the string of Heads and Tails, thereby creating a random number between $0$ and $1$.  With probability $p$ this random number is in the interval $(0,p)$ and with probability $1-p$ it's in the interval $(p,1)$ (and with probability $0$ it's exactly equal to $p$.) The point is, you don't need to pay any attention to your friend's tosses, because the interval the number lands is was determined with the final toss you made.
