# Coin tossing: Streak count

I have a special request with regards to probability.

Let's say I toss a coin 400 times.

What I need to know is the average number of streaks of various lengths within such a sample.

How many streaks of X heads should I expect to see in such a sample?

How do I calculate that for various values of X?

First of all, I will understand that a streak of $X+1$ heads count as two streaks of $X$ heads. Let's say that coins from the first to the $X+1$ are head, then you have a streak from $1$ to $X$ of $X$ heads and one from $2$ to $X+1$. Otherwise, you need to define how we count streaks.

Now, let $X_n$ be the event of having a streak of $n$ coins, and let $X_n^i$ the event of having a streak of $n$ heads begining on the $i^{th}$ coin. Note that $P(X_n^i)=P(X_n^j)=\frac{1}{2^n}\ \ \forall i,j\in[1,401-n]$.

$$E[X_n]=E[X_n^1+X_n^2+...+X_n^{401-n}]=E[(401-n)X_n^i]=(401-n)E[X_n^i]=(401-n)P(X_n^i)=(401-n)\frac{1}{2^n}\\ E[X_n]=\frac{401-n}{2^n}$$

Note that in my answer $n$ is what you called $X$

$E[X_n]$ for $n\in [3,8]$

$E[X_3]=49.75\\ E[X_4]=24.8125\\ E[X_5]=12.375\\ E[X_6]\approx 6.1719\\ E[X_7]\approx 3.0781\\ E[X_8]\approx 1,5352$

Under a new definition of a streak, the answer changes a bit. If we define a $n-streak$ as having $n$ heads in a row and no more we can use a similar version of the previous formula, where we include the tails needed before and after the streak.

So now, using the same notation as before, $P(X_n^i)=P(X_n^j)=\frac{1}{2^{n+2}}\ \ \forall i,j\in [2,400-n]$. Note that in this case we have special values: $P(X_n^1)=P(X_n^{401-n})=\frac{1}{2^{n+1}}$ and when $n=400$, the answer is simply $E[X_{400}]=\frac{1}{2^{400}}$ (don't bother using the formula).

Having that, we can take back the formula we used,

$$E[X_n]=E[X_n^1+X_n^2+...+X_n^{401-n}]=E[2X_n^1+(399-n)X_n^2]= 2E[X_n^1]+(399-n)E[X_n^2]= \frac{2}{2^{n+1}}+\frac{399-n}{2^{n+2}}=\\ E[X_n]=\frac{403-n}{2^{n+2}}$$

$E[X_n]$ for $n\in [3,8]$

$E[X_3]=12.5\\ E[X_4]\approx 6.234\\ E[X_5]\approx 3.109\\ E[X_6]\approx 1.551\\ E[X_7]\approx 0.773\\ E[X_8]\approx 0.386$

• Thanks for commenting. Unfortunately, I'm not used to reading these formulas. Could you tell me the results for n=3 ... 8? – Chris May 27 '15 at 8:58
• Thanks a lot. But I'm a bit surprised to see that. I tried it out experimentally in excel, and got to the following results: E[3] = 12.52 E[4] = 6 E[5] = 3.6 E[6] = 1.56 This was counted in a sample of 10000 throws – Chris May 27 '15 at 9:38
• Here how you count the number of streaks is crucial. See in the beginning of the answer how I counted them. Maybe you counted them differently. – Masclins May 27 '15 at 9:40
• Okay, I count this TTHHHHTTT as one strike of 4 heads but not 2 strikers of 2 heads. Is that clearer? – Chris May 27 '15 at 15:59
• But a 4 heads strike counts also as a 2 and 3 heads strike? Like, in your example, you'd have only a 4-strike? Or also a 3-strike and a 2-strike? – Masclins May 27 '15 at 16:06