3

You flip a fair coin until M total heads have been flipped OR N total tails have been flipped. What is the expected number of flips?

This is a generalization of this question (in which M = N).

FWIW, I can calculate the numeric solutions for small M, N in Excel. I'm just curious as to what the exact equation would be.

Thanks!


Edit:

I'm asking this question because of the Sept 10, 2021 edition of FiveThirtyEight's Riddler (specifically the Classic).

  • This problem can be formulated as a Markov chain in which state $(i,j)$ represents $i$ heads and $j$ tails, the chain starts at $(0,0)$, and the states $(M,j)$ and $(i,N)$ for $0\le j \le N$ and $0\le i \le M$ are absorbing. See this post https://math.stackexchange.com/q/3052848/693577 – Joe Sep 10 '21 at 23:33

2 Answers2

4

WLOG $N\le M$

The probability of getting the $N^{th}$ tail on the $n^{th}$ toss is

$$P(N,n) = \binom{n-1}{N-1} 2^{-n} $$The probability of getting the $M^{th}$ head on the $n^{th}$ toss is $$P(M,n) = \binom{n-1}{M-1} 2^{-n} $$ The events are mutually exclusive so the probabilities can just be added

The expected number of tosses is $$<n> = \sum_{n=N}^{N+M-1} n\cdot 2^{-n} \bigg[ \binom{n-1}{M-1} + \binom{n-1}{N-1} \bigg ] $$

I don't know how to algebraically evaluate this sum, but this Desmos file seems to do it for pretty much any values of $M$ and $N$

https://www.desmos.com/calculator/iqd7zcqecg

WW1
  • 10,804
2

If the expectation is $E_{M,N}$ then I would have thought you have the recurrence $$E_{M,N}=1+\tfrac12 E_{M-1,N}+\tfrac12 E_{M,N-1}$$ starting at $E_{M,0}=E_{0,N}=0$. There may be an easy solution, though I do not see it. Some values for small $M,N$ are

          [,1]     [,2]     [,3]     [,4]     [,5]      [,6]      [,7]
 [1,] 1.000000 1.500000 1.750000 1.875000 1.937500  1.968750  1.984375
 [2,] 1.500000 2.500000 3.125000 3.500000 3.718750  3.843750  3.914062
 [3,] 1.750000 3.125000 4.125000 4.812500 5.265625  5.554688  5.734375
 [4,] 1.875000 3.500000 4.812500 5.812500 6.539062  7.046875  7.390625
 [5,] 1.937500 3.718750 5.265625 6.539062 7.539062  8.292969  8.841797
 [6,] 1.968750 3.843750 5.554688 7.046875 8.292969  9.292969 10.067383
 [7,] 1.984375 3.914062 5.734375 7.390625 8.841797 10.067383 11.067383
 [8,] 1.992188 3.953125 5.843750 7.617188 9.229492 10.648438 11.857910
 [9,] 1.996094 3.974609 5.909180 7.763184 9.496338 11.072388 12.465149
[10,] 1.998047 3.986328 5.947754 7.855469 9.675903 11.374146 12.919647
[11,] 1.999023 3.992676 5.970215 7.912842 9.794373 11.584259 13.251953
[12,] 1.999512 3.996094 5.983154 7.947998 9.871185 11.727722 13.489838
[13,] 1.999756 3.997925 5.990540 7.969269 9.920227 11.823975 13.656906
[14,] 1.999878 3.998901 5.994720 7.981995 9.951111 11.887543 13.772224
[15,] 1.999939 3.999420 5.997070 7.989532 9.970322 11.928932 13.850578
[16,] 1.999969 3.999695 5.998383 7.993958 9.982140 11.955536 13.903057
[17,] 1.999985 3.999840 5.999111 7.996534 9.989337 11.972436 13.937747
[18,] 1.999992 3.999916 5.999514 7.998024 9.993680 11.983058 13.960403
[19,] 1.999996 3.999956 5.999735 7.998879 9.996280 11.989669 13.975036
[20,] 1.999998 3.999977 5.999856 7.999368 9.997824 11.993747 13.984391

Empirically the expectation seems to be something of the form $$2N-\frac{M^{N-1}+\cdots}{2^{M+N-2} (N-1)!}$$

where $\cdots$ is a degree $N-2$ polynomial function of $M$

  • when $N=1$ the $\cdots$ is $0$
  • when $N=2$ the $\cdots$ is $4$
  • when $N=3$ the $\cdots$ is $9M +24$
  • when $N=4$ the $\cdots$ is $15M^2 +86M+192$
  • when $N=5$ the $\cdots$ is $22M^3+203M^2+950M+1920$

and the $4,24,192,1920$ might be $2^{N-1}N!$

Henry
  • 169,616