[Math] The probability distribution of the number of coin flips needed to get $n$ heads or $k$ tails

probability

Suppose we are flipping a fair coin. Let n,k be fixed numbers. We flip the coin until we get a total of n heads or a total of k tails. What is the probability distribution of the number of coin flips needed to get n heads or k tails? If it is easier, what is the expectation? The support of this discrete distribution is from the min(n,k) to n+k-1.

Best Answer

The probability of getting the $n$-th head on the $r$-th toss, is that of the $r$-th toss being a head, and exactly $n-1$ of the first $r-1$ tosses being heads, that is $p_r= 2^{-r}\binom{r-1}{n-1}$. In this case this probability is only relevant if $r-n<k$. There is a similar formula for the probability that the $k$-th tail occurs on the $r$-th toss, that is $q_r=2^{-r}\binom{r-1}{k-1}$. So the probability you seek is $p_r+q_r$ if $n\le r<k+n$ and $k\le r<k+n$, is $p_r$ if $n\le r<k+n$ and $k>r$ and is $q_r$ if if $k\le r<k+n$ and $r>k$.