Expected length of the longest streak of heads, when the coin is being tossed until $n$ tails

expected valuemaxima-minimaprobability

Suppose we tossed a coin with probability of tails $p$ until we got $n$-th tails. What is the expected length of the longest consecutive string on heads under this condition?

Let’s denote the length of the streak of heads, that is exactly before $i$-th tails as $X_i$. It is not hard to see, that all $X_i$ are i.i.d. and are distributed geometrically with parameter $p$. Thus our question can be reworded in the following way:

Suppose $X_1, … , X_n$ are i.i.d. random variables, geometrically distributed with parameter $p$. What is $E[\max(X_1, … , X_n)]$?

If the exact answer is too complicated, then asymptotic is also OK.

Best Answer

Let's work with the reworded version of your problem and let $Y = \max(X_1, \ldots, X_n).$ For discrete random variables having range $\{0,1,\ldots\}$ we have $\mathbb{E}[Y] = \sum_{y=0}^{\infty} \mathbb{P}(Y>y).$ We have the chain of equalities:

$$ \mathbb{P}(Y>y) = 1- \mathbb{P}(Y \leq y) = 1- \mathbb{P}(X_1\leq y, \ldots, X_n \leq y) = 1 - \mathbb{P}(X_1 \leq y)^n$$

and $\mathbb{P}(X_1 \leq y) = 1 - \mathbb{P}(X_1 > y) = 1 - (1-p)^y,$ so

$$ \mathbb{E}[Y] = \sum_{y=0}^{\infty} \left( 1 - (1-(1-p)^y)^n \right) =\sum_{y=0}^{\infty} \sum_{k=1}^n (-1)^{k+1} \binom{n}{k} (1-p)^{yk} $$ $$= \sum_{k=1}^n (-1)^{k+1} \binom{n}{k} \cdot \frac{1}{1-(1-p)^k}$$

Related Question