Problem 11.12 Easy Free 1 variation

Simulating a One-Third Event

You want to simulate an event of probability 1/31/3 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 14\tfrac14, so a round is decisive with probability p=34p=\tfrac34, independently of earlier rounds.

Let NN be the total number of flips. Condition on the first round. With probability 34\tfrac34 it is decisive and N=2N=2. With probability 14\tfrac14 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 NN. Hence

E[N]=34⋅2+14(2+E[N]),\mathbb{E}[N]=\tfrac34\cdot 2+\tfrac14\bigl(2+\mathbb{E}[N]\bigr),

which gives 34 E[N]=2\tfrac34\,\mathbb{E}[N]=2, so E[N]=83\mathbb{E}[N]=\tfrac83.

Alternative. The number of rounds KK is Geom(34)\mathrm{Geom}(\tfrac34) on {1,2,… }\{1,2,\dots\}. So E[K]=43\mathbb{E}[K]=\tfrac43 and E[N]=2 E[K]=83\mathbb{E}[N]=2\,\mathbb{E}[K]=\tfrac83.

The scheme is correct: given that a round is decisive, it is HH with probability 1/43/4=13\frac{1/4}{3/4}=\frac13.

E[N]=83\boxed{\mathbb{E}[N]=\tfrac{8}{3}}

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.

Variation 11.12a

You wish to sample from X∼Beta(3,2)X \sim \mathrm{Beta}(3,2), with density f(x)=12x2(1−x)f(x) = 12x^2(1-x) on (0,1)(0,1), by acceptance-rejection. You can generate uniform random points in the rectangle Ra=[0,1]×[0,a]R_a = [0,1]\times[0,a] for a chosen constant a>0a>0, and you accept a point (X,Y)∈Ra(X,Y)\in R_a as a sample whenever it lies under the curve ff, rejecting it otherwise. Choosing aa 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 a≥max⁡fa\ge \max f.

The point is uniform on RaR_a, so it is accepted with probability

area under farea of Ra=1a.\frac{\text{area under } f}{\text{area of } R_a}=\frac{1}{a}.

This is largest when aa is as small as possible, so take a=max⁡fa=\max f.

To find the maximum, note f′(x)=24x−36x2=12x(2−3x)f'(x)=24x-36x^2=12x(2-3x), which vanishes on (0,1)(0,1) only at x=23x=\tfrac23. There

f ⁣(23)=12⋅49⋅13=169.f\!\left(\tfrac23\right)=12\cdot\tfrac49\cdot\tfrac13=\tfrac{16}{9}.

Since f(0)=f(1)=0f(0)=f(1)=0, this is the maximum, so a=169a=\tfrac{16}{9}.

Each point is then accepted independently with probability 916\tfrac{9}{16}. The number of points generated per accepted sample is Geom(916)\mathrm{Geom}(\tfrac{9}{16}), with mean 169\tfrac{16}{9}. The expected number of rejected points is therefore

169−1=79.\tfrac{16}{9}-1=\tfrac79.
79\boxed{\tfrac{7}{9}}