The idea
We have seen how the Binomial distribution allows us to model the number of successes that will occur in n trials where we know the probability of success p. Sometimes, however, we know the target number of successes (s), we know the probability p, but we wish to estimate the number of trials that we will need to complete in order to achieve these s successes, assuming we stop once the sth success has occurred.
...
For example, imagine you have to interview ten people (s) that have completed a marathon at some time in their life, knowing that 20% (p) of all people have ever ran a marathon. If you would go out on the street and randomly ask people, how many people (n) would you have to ask (estimate n)? In this case, n is the random variable.
Derivation of the Negative Binomial distribution
Now that we have the binomial distribution, we can readily determine the distribution for n. Let x be defined as the total number of trials needed to obtain s successes. Since the very last trial is by definition a success, by the (x-1)th trial we must have observed (s-1) successes and (x-1) - (s-1) = x-s failures. You can see this in the figure below.
...