Simulating a One-Third Event
You want to simulate an event of probability using only fair coin flips, via the following scheme: flip a fair coin twice. If the result is HH, declare the event to have occurred. If the result is HT or TH, declare that it did not occur. If the result is TT, repeat the two-flip experiment from scratch (independently of the past). Find the expected total number of coin flips used.
Work it out, then compare with the answer.
SolutionShow the worked solution
Each two-flip round ends the procedure unless it shows TT. That happens with probability , so a round is decisive with probability , independently of earlier rounds.
Let be the total number of flips. Condition on the first round. With probability it is decisive and . With probability it is TT. Then two flips have been spent and the process starts afresh, so the remaining number of flips has the same distribution as . Hence
which gives , so .
Alternative. The number of rounds is on . So and .
The scheme is correct: given that a round is decisive, it is HH with probability .
Key idea. With independent rounds, the expected cost is (cost per round)(success probability per round).
Variations
The same idea with a twist. Each solution gives only the changed step.
You wish to sample from , with density on , by acceptance-rejection. You can generate uniform random points in the rectangle for a chosen constant , and you accept a point as a sample whenever it lies under the curve , rejecting it otherwise. Choosing to be the smallest value that still makes this a valid rejection scheme (minimizing the rejection rate), find the expected number of rejected points per accepted point.
Work it out, then compare with the answer.
Solution
The scheme is valid only if the curve lies inside the rectangle, that is .
The point is uniform on , so it is accepted with probability
This is largest when is as small as possible, so take .
To find the maximum, note , which vanishes on only at . There
Since , this is the maximum, so .
Each point is then accepted independently with probability . The number of points generated per accepted sample is , with mean . The expected number of rejected points is therefore