TITLE: Distribution of a random variable in a coin toss
QUESTION [7 upvotes]: Amanda tosses a fair coin until she gets $H$. Let $X$ be the number of these tosses. 
After that she tosses $X$ fair coins, each one until she gets $H$. Let $Y_i$ be the number of tosses for the coin $i\in\{1,\dots,X\}$.
Finally, Let $S=Y_1+Y_2+\dots+Y_X$ the total number of tosses (excluding the first $X$ tosses).

Prove: $S\sim \mathrm{Geo}\left(\frac14 \right)$

My try: 
I know that $(S|X=k)\sim \mathrm{NegBin}(k, 1/2)$ as sum of geometric random variables. How can I conclude that $S\sim \mathrm{Geo}(1/4 )$?

REPLY [7 votes]: Consider a biased labeled dice $Z$ where $P(Z=T)=1/2$, $P(Z=H)=1/4$, $P(Z=END)=1/4$. We sample from $Z$ until we get $Z=END$ to form a sequence $( Z_i )$. For example $( Z_i ) = (T, H, H, T, T, H, T,END)$. The length of the sequence clearly follows $Geom(1/4)$.
We can biject $( Z_i )$ to $(Y_1, Y_2, ... , Y_X)$ in the obvious way: 
$$( Z_i ) = (T, H, H, T, T, H, T, END) \leftrightarrow (2,1,3,2)=(Y_1,Y_2,Y_3,Y_4)$$
i.e. $X=4$ and the tosses were $(T,H)$,$(H)$,$(T,T,H)$,$(T,H)$. Notice $length(Z_i)=S$ and $num((Z_i)=H)+1=X$
The probability of the two are equal: $P((Z_i))=\frac{1}{2^{length+num((Z_i)=H)+1}}$ and $P((Y_i))=\frac{1}{2^{S+X}}$. Thus, $S$ follows the same distribution as length of $(Z_i)$.