Consecutive strings of heads problem I am working on this homework question and I am wondering am I on the right track?
Question:
A fair coin is tossed ten times and the outcome (H for heads, T for tails) is listed as
a sequence. For example, the result can be H, H, H, T, T, H, T, H, H, T . We shall
say that a run is a maximal sequence of H’s. In the previous example, there are
three runs of lengths 3, 1 and 2 respectively. Please answer the following questions:
a. What is the probability that a run starts on the first toss (like the
example)?
b. What is the probability that the first run starts on the first toss and
ends on the third toss (like the example)?
c. What is the probability that the first run starts on the first toss and
the second run starts on the sixth toss (like the example)?
d. The goal of this problem is to compute the average length of a run that
starts on the first toss. Let X denote the length of a run that starts on the first
toss. What are the possible values of X? For each value j, compute the probability
that X = j. Finally, compute the expected value of X.
Answer:
a. $\frac{1}{2}$
b. $\frac{1}{16}$ (because the fourth one has to be a tail)
c. HTTTTH, HHTTTH, HHHTTH, HHHHTH so $4 \times \frac{1}{64} = \frac{1}{16}$
d.

*

*when $j = 1$, $X = 1$ (probability of $\frac{1}{2}$)

*when $j = 2$, $X = 1$ (probability of $\frac{1}{2}$) or $X = 2$ (probability of $\frac{1}{4}$)

*when $j = 3$, $X = 1$ (probability of $\frac{1}{2}$) or $X = 2$ (probability of $\frac{1}{4}$) or $X = 3$ (probability of $\frac{1}{8}$)

*when $j = n$, $X \in [1 \dots n]$ (probability of $\frac{1}{2}, \frac{1}{4}, \dots ,\frac{1}{2^n}$)

So $E(X) = 1 \times \frac{1}{2} + 2 \times \frac{1}{4}+ 3 \times \frac{1}{8}+ \dots n \times \frac{1}{n^2}$ (Not sure if this can be written in a more simplified way ...)
 A: Parts (a), (b), and (c) look good. For (d), your count is off-by-one on each run. For instance, compare $j=3$ to your answer to (b). The answer that follows works out part (d) from scratch. Try to fill in the blanks on your own before clicking to reveal spoilers.

For $X = 1$, we need a run whose first tails is on toss $1 + 1 = 2$, hence $\mathbb{P}(X = 1) = \bigl( \frac12 \bigr)^2 = \frac14$.
For $X = 2$, we need a run whose first tails is on toss $2 + 1 = 3$, hence $\mathbb{P}(X = 2) = \bigl( \frac12 \bigr)^3 = \frac18$.
In general, for $X = j$, we need a run whose first tails is on toss $j + 1$, hence

 $$ \mathbb{P}(X = j) = \biggl( \frac12 \biggr)^{j+1} = \dfrac1{2^{j+1}}. $$

In order to calculate the expected value, we must sum the infinite series

 $$ \mathbb{E}(X) = \sum_{j=0}^\infty j \, \mathbb{P}(X = j) = \sum_{j=0}^\infty \frac{j}{2^{j+1}}. $$

This is the evaluation of the power series

 $$ \sum_{j=0}^\infty j \, x^{j+1} \quad\text{at}\quad x = \tfrac12$$

Usual manipulations of well-known power series and differentiation yield

 \begin{align} \sum_{j=0}^\infty j \, x^{j+1} &= \sum_{j=0}^\infty \frac{\mathrm{d}}{\mathrm{d}x} x^j \\ &= \frac{\mathrm{d}}{\mathrm{d}x} \sum_{j=0}^\infty x^j \\ &= \frac{\mathrm{d}}{\mathrm{d}x} \biggl[ \frac{1}{1-x} \biggr] \\[2pt] &= \frac{1}{(1-x)^2} \end{align}

Hence, the expectation is

 $$ \mathbb{E}(X) = \left. \frac{1}{(1-x)^2} \right\rvert_{x = \frac12}= 4. $$

