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?
 A: 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
$
