What is the negative binomial distribution?
The negative binomial distribution models the number of failures x that occur before the k-th success in a sequence of independent Bernoulli trials, where each trial succeeds with probability p. This calculator uses the "number of failures before the k-th success" parameterization, so the random variable takes values x = 0, 1, 2, ... It returns the probability mass f, the lower cumulative probability P, or the upper (survival) probability Q, and tabulates the chosen function over a range of x values.
How to use it
Pick which function to evaluate: f (probability mass), P (lower cumulative), or Q (upper cumulative). Enter the required number of successes k (a positive integer), the per-trial success probability p (between 0 and 1), the starting x value, the step between rows, and how many rows to generate. The table lists each x and the corresponding probability; the mean and variance of the failure count are also shown.
The formula explained
The probability mass function is $$f(x,k,p) = \binom{x+k-1}{x}\,p^{k}\,(1-p)^{x}$$ where \(C\) is the binomial coefficient. The lower cumulative distribution is $$P(x,k,p) = \sum_{t=0}^{x} \binom{t+k-1}{t}\,p^{k}\,(1-p)^{t}$$ The upper cumulative (survival) function is $$Q(x,k,p) = 1 - \sum_{t=0}^{x-1} \binom{t+k-1}{t}\,p^{k}\,(1-p)^{t}$$ which equals the sum of \(f(t)\) for all \(t \ge x\). The mean number of failures is \(\frac{k(1-p)}{p}\) and the variance is \(\frac{k(1-p)}{p^{2}}\).
Worked example
With \(k = 4\), \(p = 0.4\), find \(f(x=2)\): \(\binom{5}{2} = 10\), \(p^{4} = 0.0256\), \((0.6)^{2} = 0.36\), so $$f = 10 \times 0.0256 \times 0.36 = 0.09216$$ The lower cumulative $$P(2) = f(0)+f(1)+f(2) = 0.0256 + 0.06144 + 0.09216 = 0.1792$$ The survival $$Q(2) = 1 - P(1) = 1 - (0.0256 + 0.06144) = 0.91296$$
FAQ
Does x count successes or failures? Here x counts failures before the k-th success. Total trials would be x + k.
What if p = 1? No failures are possible, so \(f(0) = 1\) and \(f(x) = 0\) for \(x > 0\).
What if p = 0? The distribution is degenerate (infinitely many failures expected), and \(f(x) = 0\) for every finite x.