Q:

Finding pmf and mgf of the number of flips of a fair coin required to observe the first head-tails on consecutive flips.

Let $X$ equal the number of flips of a fair coin that are required to observe the first head-tails on consecutive flips.
(a) Find the pmf of $X$.
(b) Find the mgf of $X$.

For (a) I've read online suggestions to use tree diagram but still I am unsure of how using the tree diagram will help formulate the answer.

A:

I guess it is an exercise from Hogg, Tanis, Zimmerman's Probability and Statistical Inference. Anyway, the hint is that the only possible type of scenario is
$$\underbrace{\text{T}\cdots\text{T}}_{a\text{ T's}}\underbrace{\text{H}\cdots\text{H}}_{b\text{ H's}}\text{T}$$
for $a \geq 0$ and $b \geq 1$. So it follows that
$$P(X=x)
=\sum_{b=1}^{x-1} P\bigl( \underbrace{\text{T}\cdots\text{T}}_{x-1-b}\underbrace{\text{H}\cdots\text{H}}_{b}\text{T} \bigr)
=\sum_{b=1}^{x-1} \frac{1}{2^x}
=\frac{x-1}{2^x}.$$
This computation determines the PMF $p_X(x)$ of $X$ as:
$$ p_X(x) = \begin{cases}
(x-1)/2^x, & x \in \{2,3,4,\cdots\}, \\
0, &\text{elsewhere}.
\end{cases} $$
As a sanity check,
$$ \sum_{x=2}^{\infty} p_X(x) = \sum_{x=2}^{\infty} \frac{x-1}{2^x} = \frac{1}{2^2}\left( \frac{1}{2^0} + \frac{2}{2^1} + \frac{3}{2^2} + \cdots \right) = 1, $$
using the formula $1 + 2z + 3z^2 + 4z^3 + \cdots = \frac{1}{(1-z)^2}$. Then, by this formula again, the MGF $M_X(t)$ of $X$ is computed as
$$ M_X(t) = E[e^{tX}] = \sum_{x=2}^{\infty} e^{tx}p_X(x) = \sum_{x=2}^{\infty} (x-1) \left(\frac{e^t}{2}\right)^x = \frac{(e^x/2)^2}{\left(1 - e^x/2\right)^2} = \frac{e^{2x}}{(e^x - 2)^2}. $$

