Let \(R_k\) indicate a run of 4 heads starting at \(k\text{.}\) Since this requires 4 precise flips to come up heads, the probability of the indicated event should be
\begin{gather*}
\left(\frac{1}{2}\right)^4 = \frac{1}{16}
\end{gather*}
The very last starting flip for a run of 4 heads is flip number 97 (so that flips 97, 98, 99, and 100 would all be heads). Then \(S = R_1 + R_2 + \dotsb + R_{97}\) precisely counts the number of runs of 4 heads. Using linearity:
\begin{align*}
\E(S) \amp = \E(R_1 + R_2 + \dotsb + R_{97}) \\
\amp = \E(R_1) + \E(R_2) + \dotsb + \E(R_{97}) \\
\amp = \underbrace{\frac{1}{16} + \frac{1}{16} + \dotsb + \frac{1}{16}}_{97 \text{ times}} \\
\amp = \frac{97}{16} \\
\amp \approx 6.
\end{align*}
Notice that, unlike
ExampleΒ 3.1.11, the events being indicated here are
not independent from each other. Linearity is unaffected by the fact that that the runs of heads can overlap.