Conditional Expected Waiting Time for the Earlier of Two Coin Tosses
Summary
The problem asks for the expected number of flips Alex makes until his first head, given that Alex finishes strictly before Blake. The solution models each player’s waiting time as an independent geometric random variable with success probability one half. For each possible value k of Alex’s waiting time, it multiplies the probability that Alex finishes at k by the probability Blake takes longer, then normalizes by the probability that Alex is earlier.
This gives an earlier-finish probability of one third and a conditional distribution for Alex’s waiting time proportional to powers of one quarter. Summing that distribution’s weighted values yields an expected wait of four thirds of a flip count. A simulation is included as a numerical check and reports a value close to the calculation. The result depends on independent fair flips and the strict ordering condition; the attached response is presented as a long comment rather than a formal accepted solution.
Key ideas
- Each player’s flips until the first head follow an independent geometric distribution with success probability one half.
- The probability that Alex finishes strictly before Blake is one third.
- Conditioning on Alex finishing first weights each possible waiting time by the chance Blake takes longer.
- The conditional expected number of flips for Alex is four thirds.
- A simulation is shown as a numerical check of the analytic calculation.
Tags
Full text
# Answer by autoencoder (score 0, accepted)
# two guys flip fair coins until they obtain their first heads. it takes strictly fewer flips for one to get his first heads than the other
Alex and Blake each flip fair coins until they obtain their first heads, respectively. Given that it takes strictly fewer flips for Alex to get his first heads than Blake, compute the expected number of flips Alex performed.
MY approach - case 1 - TH (blake got H and there is only one way for alex to get a H which is the first position). case 2 - TTH (blake got in 3rd step and now alex could have gotten heads in one of the 2 ways )
and so on , got me to an expression like this -
E(BLAKE) = ΣnC1 * (n+1)/2^(n+1) for n>=1 up till inf..
now let the expected steps by alex be E(ALEX) then i assumed
E(alex) + 2 = E(blake) {As once alex gets a head it i assumed for blake to get a head now is a std problem where to get a head it takes 2 steps....}
through this approach i am not getting the right answer ....
can anyone figure out where i went wrong and suggest some other intuitive sol.
## Answer by autoencoder (score 0, accepted)
https://quant.stackexchange.com/a/79924
Disclaimer: This is just a long comment and not an answer. My suggestion is that when stuck with these sort of problems you might find large language models helpful, but definitely use with caution. Recently I've been following the AI Mathematical Olympiad and I'm quite impressed with the capability of LLMs to solve math problems. I also tried a few problems on QuantGuide with success so I think asking LLMs is not really a bad idea. I know ChatGPT generated answers are discouraged but I'm attaching it for what it's worth, I also included a python snippet of my simulated result just for verification.
ChatGPT output:
To solve the problem, we denote the number of flips until the first heads for Alex by $ X $ and for Blake by $ Y $. Both $ X $ and $ Y $ are geometrically distributed with parameter $ p = 0.5 $, i.e.,
$ P(X = k) = \left( \frac{1}{2} \right)^k, \quad P(Y = k) = \left( \frac{1}{2} \right)^k \quad \text{for} \quad k = 1, 2, 3, \ldots $
We need to compute the expected number of flips Alex performed given that $ X < Y $.
First, we calculate the probability $ P(X < Y) $. The random variables $ X $ and $ Y $ are independent, so
$ P(X < Y) = \sum_{k=1}^\infty P(X = k) P(Y > k) $
Since $ P(Y > k) = \left( \frac{1}{2} \right)^k $, we have
$ P(X < Y) = \sum_{k=1}^\infty \left( \frac{1}{2} \right)^k \left( \sum_{j=k+1}^\infty \left( \frac{1}{2} \right)^j \right) $
The sum inside the series is geometric:
$ \sum_{j=k+1}^\infty \left( \frac{1}{2} \right)^j = \left( \frac{1}{2} \right)^{k+1} \sum_{j=0}^\infty \left( \frac{1}{2} \right)^j = \left( \frac{1}{2} \right)^{k+1} \cdot \frac{1}{1 - \frac{1}{2}} = \left( \frac{1}{2} \right)^{k+1} \cdot 2 = \left( \frac{1}{2} \right)^k $
Thus,
$ P(X < Y) = \sum_{k=1}^\infty \left( \frac{1}{2} \right)^k \cdot \left( \frac{1}{2} \right)^k = \sum_{k=1}^\infty \left( \frac{1}{2} \right)^{2k} = \sum_{k=1}^\infty \left( \frac{1}{4} \right)^k $
The series is geometric with the first term $ a = \frac{1}{4} $ and common ratio $ r = \frac{1}{4} $:
$ P(X < Y) = \frac{\frac{1}{4}}{1 - \frac{1}{4}} = \frac{\frac{1}{4}}{\frac{3}{4}} = \frac{1}{3} $
Next, we need the expected number of flips $ E[X \mid X < Y] $. Using the law of total expectation, conditioned on $ X < Y $:
$ E[X \mid X < Y] = \sum_{k=1}^\infty k \cdot P(X = k \mid X < Y) $
The conditional probability $ P(X = k \mid X < Y) $ is
$ P(X = k \mid X < Y) = \frac{P(X = k \cap X < Y)}{P(X < Y)} = \frac{P(X = k) P(Y > k)}{P(X < Y)} = \frac{\left( \frac{1}{2} \right)^k \left( \frac{1}{2} \right)^k}{\frac{1}{3}} = 3 \left( \frac{1}{2} \right)^{2k} = 3 \left( \frac{1}{4} \right)^k $
Thus,
$ E[X \mid X < Y] = \sum_{k=1}^\infty k \cdot 3 \left( \frac{1}{4} \right)^k $
We use the formula for the expected value of a geometric series with $ a = 3 \left( \frac{1}{4} \right) $ and $ r = \frac{1}{4} $:
$ \sum_{k=1}^\infty k \cdot r^k = \frac{r}{(1 - r)^2} \quad \text{where} \quad r = \frac{1}{4} $
$ \sum_{k=1}^\infty k \cdot \left( \frac{1}{4} \right)^k = \frac{\frac{1}{4}}{(1 - \frac{1}{4})^2} = \frac{\frac{1}{4}}{\left( \frac{3}{4} \right)^2} = \frac{\frac{1}{4}}{\frac{9}{16}} = \frac{1}{4} \cdot \frac{16}{9} = \frac{4}{9} $
Therefore,
$ E[X \mid X < Y] = 3 \cdot \frac{4}{9} = \frac{4}{3} $
So, the expected number of flips Alex performed given that it takes fewer flips for him to get his first heads than Blake is:
$ \boxed{\frac{4}{3}} $
Numerical simulation:
```
import numpy as np
def flip_till_first_head():
num_flips = 0
while True:
num_flips += 1
if np.random.choice(['head', 'tail']) == 'head':
return num_flips
n_rounds = 1000_0000
result = np.zeros((n_rounds, 2))
for i in range(n_rounds):
flips_alex = flip_till_first_head()
flips_blake = flip_till_first_head()
result[i, 0] = flips_alex
result[i, 1] = flips_blake
mask = result[:, 0] < result[:, 1]
print(result[mask, 0].mean())
1.3333652386583321
```
```Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.