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!

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}.$$
