Flipping a Coin 10 Times and Getting a Sequence of Heads I toss a fair coin $10$ times resulting in a sequence of heads and tails. Let $X$ be the number of times that the sequence $HH$ appears. $HH$ appears thrice here.

Solution:
The example goes, say we flip a coin $10$ times and you get all heads then we have $HH$ appears $10$ times. (I would write it out, but my LateX Skills are not up to par.)
And we see $P(HH) = \frac{1}{4}$ because we have $.5$ for heads and tails for the two coins.
$X = HH$ appears.
This is where I don't understand what happens: $\sum_{n=0}^9P(X)\cdot X = \frac{9}{4}$.
When I thought of it, do you factor out $P(X)$ because it is always $\frac{1}{4}$, but I am wrong. Any help would be awesome!
 A: Let $X_j$ be the indicator random variable of HH appearing at position $j$ for $j=1,2,\dots, 9$. Notice that these aren't quite independent from each other so I don't know if the binomial solution is entirely accurate, although it gives the correct expected value. But we can anyway use linearity of the expectation. As $X=\sum_{j=1}^9 X_j$, in another words $X$, which is the total number of appearances of HH, is the sum of the ones that did occur, we get that
$$\mathbb{E}[X] = \mathbb{E} \left[\sum_{j=1}^9 X_j \right] =\sum_{j=1}^9  \mathbb{E}[X_j] = \sum_{j=1}^9 \frac{1}{4} = \frac{9}{4}.$$
A: $X$ follows a bionomial distribution with success probability $p=1/4$ and $n=9$ the number of trials. Too see this let $X$ be the number of $HH$ appeared in a flip coin of 10 tosses. Clearly, as you said to get $HH$ twice in a row has probability equal to $p=1/4$. So, you look at your problem from the point of view that $HH$ is your success outcome and the rest $\{HK,KH,KK\}$ consists of the failure outcomes. Now you look for how many possible ways you have in order to get $HH$ in $10$ tosses. There are $9$ ways, in order to figure this out you look at the positions where the first $H$ can appear in a sequence of $HH$. It can appear in any of the first $9$ positions. So, we end up that $X\sim Bionomial(9,1/4)$. And this has $E[X]=np=9/4$.
