Waiting for the k'th success
The number of independent Bernoulli trials until the first success is observed has a geometric distribution. We now generalise this to consider the number of trials until we observe the \(k\)'th success.
Definition
In a sequence of independent Bernoulli trials with \(P(success) = \pi\) in each trial, the number of trials until the \(k\)'th success is observed has a distribution called a negative binomial distribution.
\[ X \;\; \sim \; \; \NegBinDistn(k, \pi) \]The probability function for the negative binomial distribution can be fairly easily obtained.
Negative binomial probability function
If a random variable has a negative binomial distribution, \(X \sim \NegBinDistn(k, \pi) \), then its probability function is
\[ p(x) = \begin{cases} \displaystyle{{x-1} \choose {k-1}} \pi^k(1-\pi)^{x-k} & \quad \text{for } x = k, k+1, \dots \\[0.5em] 0 & \quad \text{otherwise} \end{cases} \]If the \(k\)'th success arises on the \(x\)'th trial, there must have been exactly \((k - 1)\) successes in the first \((x - 1)\) trials, followed by a success in the \(x\)'th trial.
The probability of \((k - 1)\) successes in the first \((x - 1)\) trials can be found as a probabilitiy from the binomial distribution, and the probability that the \(x\)'th trial is a success is independently \(\pi\), so
\[ \begin{align} p(x) & \;=\; \pi \;\times\;{{x-1} \choose {k-1}} \pi^{k-1}(1-\pi)^{(x-1)-(k-1)} \\ &\; =\; {{x-1} \choose {k-1}} \pi^k(1-\pi)^{x-k} \end{align} \]From its definition, the negative binomial distribution is identical to the geometric distribution when \(k=1\).
Shape of negative binomial distributions
The diagram below shows some possible shapes of negative binomial distributions. Use the sliders to see the effect of changing the parameters \(k\) and \(\pi\).
When \(k=1\), we are just waiting for the first success, so the distribution is a geometric one with its highest probability at \(x=1\) — the mode of the distribution. With larger \(k\) the mode is higher than the minimum possible value, provided \(\pi\) is not too close to one.
When \(\pi\) is small, there are many small probabilities so the bar chart does not show the distribution clearly. Turn off the checkbox Show zero-one axis to expand the probability scale, then adjust the parameters again.
Since it has two parameters, the negative binomial family of distributions includes distributions with more different shapes than the geometric distribution and even becomes fairly smooth and symmetric when \(\pi\) is small and \(k\) is large.