# In a statitical experiment involving independent coin tosses, what is the number of heads required to get $m$ tails?

I know that the solution is a negative binomial distribution. However, I was a looking for a proof for the same along the following lines. If the number of coin tosses is fixed to be $n$, then the distribution of number of heads follows a binomial distribution, that is $$P(N_h = n_h) = \frac{n!}{n_h!(n-n_h)!} p^{n_h}(1-p)^{n-n_h}\:,$$ where $p$ is the probability of observing a head.

Hence, if we condition on the number of tails observed $m$, we should be able to get the desired distribution. Hence,

\begin{align*} P(N_h = n_h| N_t = m) &= \frac{P(N_h = n_h, N_t = m)}{P(N_t = m)} \\ &= 1{\{n_h+m =n\}} \end{align*}

I know that this is the wrong way to this problem. I was wondering about how to proceed correctly.

Assume that we have observed $m$ tails. The last coin toss must have given us a tail - otherwise we would have stopped earlier. We can now count in how many ways this can occur with $n_h$ heads. Thus, we have $n_h + m$ tosses, and the last one is fixed (tail). We then have to place $m - 1$ tails in $n_h + m - 1$ places. We can do this in

$$k_{n_h} =\pmatrix{n_h + m - 1 \\ m - 1}$$

ways, using binomial coefficients. Each of them have equal probability, namely $p^{n_h}(1-p)^m$, using the independence of the tosses. Each of the $k_{n_h}$ different ways are obviously disjoint events, and therefore we can get the desired probability simply by summing their respective probabilities. All in all,

$$P(N_h = n_h | N_t = m) = \pmatrix{n_h + m - 1 \\ m - 1} \cdot p^{n_h}(1-p)^m,\ n_h \in \mathbb{N}_0,\ m \in \mathbb{N}.$$

This is exactly the negative binomial distribution with parameters $m$ and $p$.

I'm not quite sure of understanding the question but I'll give it a try.

In order to get $m$ tails you need to get $n-m$ heads, if you calculate $P(N_h = n-m)$ you will get the probability of getting $n-m$ heads and $m$ tails.