Let me start with a story.
Our mathematics teacher asked us this question:
Suppose I give you two balls, one black and the other white, then can you give me the white ball with $1/2$ probability?
The answer was easy, we just toss a fair coin and if it lands Heads, we give the black ball, else we give the white one.
Then, we were asked a second question:
Suppose I give you two balls, one black and the other white, then can you give me the white ball with any fractional probability that I tell you? The probability can be like $2/3$ or $7/10$ or $12/100$?
We can answer this question by making {denominator} number of equal pieces of paper and writing White on {numerator} number of pieces and Black on the remaining ones, and then mix all the papers together and take a piece of paper randomly from them. For example, if we want to give the White ball with a probability of $7/10$, we make 10 paper pieces and write White on 7 of them and Black on the remaining three. Now we randomly pick up a piece of paper and then give the ball which has the colour same as that of written on the paper.
Now, I have another question:
If I want to have the white ball with a (well-defined) irrational probability (like $1/\sqrt2$, $\sqrt{12}/\sqrt{33}$ or $1/\pi$), what should be the answer?
By well-defined, I mean that the number should be obtainable by fairly common mathematical methods and not man-made irrational numbers like $0.1234567891011121314151617181920...$, though, if any technique can obtain such a number, then better.
For certain probabilities, there are certain interesting algorithms to produce them without having to calculate their binary expansions, transcendental functions, or the like.
For instance, to produce the probability $1/\pi$, the following algorithm will do (Flajolet et al. 2010), which is based on a series expansion by Ramanujan:
For the probability $1/\sqrt{2}$, there is a recursive algorithm as follows:
Note how this algorithm is recursive. Also, for $\sqrt{12}/\sqrt{33}$ there is a similar recursive algorithm based on that number's continued fraction expansion $[0; 1, \overline{1, 1, 1, 12, 1, 1, 1, 2}]$, as well as a more general algorithm for other continued fraction expansions.
Other examples include 1 divided by the golden ratio and $e^{-1}$.
REFERENCES: