2
$\begingroup$

How to find the expected number of running heads of a specific length (say 'k' exactly) in 'n' tosses of a coin (fair/biased). For example, consider the output of a coin toss as follows "THHHTHTHHHTTTHHTHHT". The number of running head of length 1,2 and 3 are 1,2 and 2 respectively.

$\endgroup$
2
$\begingroup$

Index the tosses by $i=1,2,\ldots, n.$ Let $X_{i;k}$ be the indicator of the event "a run of exactly $k$ heads terminates at toss $i.$" From the formula of expectation (as the product of values by their probabilities), the expectation of any indicator is its chance of being $1:$

$$E[X_{i;k}] = \Pr(X_{i;k}=1).$$

When the coin has a chance $p$ of heads (independently at each toss) and therefore a chance $q=1-p$ of tails, the independence assumption shows the chance that $X_{i;k}=1$ must be the chance of $k$ heads preceded and followed by either (a) a tails or (b) the terminus of the sequence. Thus,

  1. When $i\lt k,$ $\Pr(X_{i;k}=1)=0.$

  2. When $i=k,$ $\Pr(X_{i;k}=1) = p^kq$ if $k\lt n$ and otherwise $\Pr(X_{i;k}=1)=p^k.$

  3. When $k \lt i \lt n,$ $\Pr(X_{i;k}=1)=p^kq^2.$

  4. When $i=n$ and $n\gt k,$ $\Pr(X_{i;k}=1)=p^k q.$

Let $N_{k;n}$ be the number of runs of exactly length $k$ in the sequence. Since

$$N_{k;n} = \sum_{i=1}^n X_{i;k},$$

taking expectations gives

$$E[N_{k;n}] = \sum_{i=1}^n E[X_{i;k}]$$

yielding

$$E[N_{k;k}] = p^k,$$

$$E[N_{k;k+1}] = 2p^kq,$$

and generally for $n\ge k+2,$

$$E[N_{k;n}] = 2p^kq + (n-k-1)p^kq^2.$$

$\endgroup$
1
  • $\begingroup$ Thank you very much @whuber. $\endgroup$ Sep 6 '20 at 12:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.