TITLE: A coin is thrown until two heads and two tails appears. What is the cumulative distribution function of this situation?
QUESTION [5 upvotes]: A coin is thrown until two heads and two tails appears. Let $Y$ be the number of throws until this happens. What is the cumulative distribution function of $Y$?
What I have gotten so far:
The last throw can end up being either head or tail. Let's look at this situations separately.
Last throw is tail:
$$\sum^n_{k=2}P(Y=k)k=0,5^k\cdot k(k-1), \qquad n\ge4.$$
This happens to also be the probability mass function when the last throw is head. Now summing up the two cases, we get
$$0,5^k\cdot k(k-1)+0,5^k\cdot k(k-1)=2k(k-1)\cdot0,5^k$$
which is the probability mass function of the situation. Does this seem correct?

REPLY [2 votes]: Hint:
The probability that the $k$-th throw is the last one is the probability of the event that

$k>3$

and
either

there is exactly one T in the previous $k-1$ throws and the $k$-th throw is T,

or

there is exactly one H in the previous $k-1$ throws and the $k$-th throw is H.

This is:
$$
\binom{k-1}1\frac1{2^{k-1}}\cdot\frac12+\binom{k-1}1\frac1{2^{k-1}}\cdot\frac12=\binom{k-1}1\frac1{2^{k-1}},
$$
where $\binom{k-1}1$ is the number of ways to order 1 T(H) and $k-2$ H(T).
Particularly this consideration proves:
$$
\sum_{k=3}^\infty\frac k{2^k}=1.
$$