Negative Binomial Distribution Calculator
Find the probability that the r-th success arrives on a given trial, or after a given number of failures, in repeated independent trials. Get exactly, at most, at least and between probabilities in either convention, plus the mean, variance, a bar chart and a table.
Waiting for the first success? That is the geometric distribution, the case r = 1.
Trials count the r successes themselves, failures do not
A whole number of at least 1
A decimal from 0 to 1
Related Calculators
Geometric Distribution Calculator
Find the probability that the first success lands on a given trial, in either textbook convention, with cumulative and range results.
Binomial Distribution Calculator
Exact, at-most, at-least and range probabilities for the number of successes in n independent trials, with the mean, variance, a bar chart and a table.
Poisson Distribution Calculator
Turn an average event rate into exact, cumulative and range Poisson probabilities, with a bar chart and a probability table.
Learn More
Poisson Distribution Explained
From an average rate to exact count probabilities: worked call-center example, the assumptions checklist, and the binomial approximation shown numerically.
Binomial vs Poisson vs Hypergeometric
Three questions decide the right counting distribution — fixed trials, independence, replacement — with one inspection scenario computed all three ways.
Before you calculate
- Decide how many successes r you are waiting for and the success probability p of each independent trial.
- Pick the convention your source uses: X counts trials up to and including the r-th success (k = r, r + 1, …), or failures before it (k = 0, 1, …). The two differ by exactly r: trials = failures + r.
- In the failures convention r may be any positive number, which is how the distribution is used for overdispersed counts. Counting trials only makes sense for a whole number r.
What the negative binomial distribution describes
A binomial experiment fixes the number of trials and counts the successes. The negative binomial turns this around: it fixes the number of successes r and counts how long it takes to get them. It is the sum of r independent geometric waiting times, so a salesperson waiting for the fifth sale, an inspector looking for the third defect or a basketball player making the tenth free throw are all negative binomial waits.
Formulas in both conventions
Trials (k = r, r + 1, …): P(X = k) = C(k − 1, r − 1) × p^r × (1 − p)^(k − r), mean r/p
Failures (k = 0, 1, …): P(X = k) = C(k + r − 1, k) × p^r × (1 − p)^k, mean r(1 − p)/p
Non-integer r: C(k + r − 1, k) = Γ(k + r) / (k! × Γ(r))
Both conventions: variance r(1 − p)/p², skewness (2 − p)/√(r(1 − p))
For the r-th success to land on trial k, exactly r − 1 of the first k − 1 trials must succeed, which can happen in C(k − 1, r − 1) ways, and trial k must succeed. The cumulative probability links to the binomial: the r-th success comes within k trials exactly when k trials contain at least r successes, so P(X ≤ k) equals the binomial “at least r” probability with n = k. With r = 1 every formula reduces to the geometric distribution.
Worked example: waiting for the third success
Each independent attempt succeeds with probability p = 0.4, and you stop at the third success (r = 3). What is the probability that it happens exactly on the 7th attempt?
- Choose the earlier successes: two of the first six attempts succeed, in C(6, 2) = 15 ways.
- Probability of one such pattern: three successes and four failures give 0.4³ × 0.6⁴ = 0.064 × 0.1296.
- Multiply: P(X = 7) = 15 × 0.064 × 0.1296 = 0.124416.
The cumulative cards give P(X ≤ 7) = 0.580096 (the third success comes within seven attempts) and P(X > 7) = 0.419904. The mean is r/p = 7.5 attempts, the variance 3 × 0.6 / 0.16 = 11.25 and the standard deviation 3.3541. Choose Between two values with a = 5 and b = 10 to find that the third success comes between the 5th and the 10th attempt with probability 0.65351. Load example reproduces the first results. Switching to the failures convention and entering k = 4 (four failures before the third success) gives the same 0.124416.
A longer wait: a shooter who makes 30% of free throws needs 5 makes (r = 5, p = 0.3). The fifth make comes exactly on the 12th attempt with probability 0.06604, within 12 attempts with probability 0.276345, and takes 5/0.3 ≈ 16.7 attempts on average.
Overdispersed counts: negative binomial vs Poisson
The negative binomial with a non-integer r is the standard model for counts whose variance exceeds their mean, which the Poisson distribution cannot represent (its variance equals its mean). In the failures convention the mean is μ = r(1 − p)/p and the variance is μ + μ²/r, so a small r means a lot of extra spread. To model a count with mean μ and dispersion r, use p = r/(r + μ).
For example r = 2 and p = 0.25 give mean 6 and variance 24, four times the variance of a Poisson with the same mean. The difference is in the tails: P(X ≥ 12) is 0.126705 for this negative binomial and only 0.020092 for a Poisson with rate 6. Choose the failures convention and enter r = 2, p = 0.25 and k = 12 to see it.
Excel, R and Python
| Software | P(X = k) | P(X ≤ k) |
|---|---|---|
| Excel | NEGBINOM.DIST(k, r, p, FALSE) | NEGBINOM.DIST(k, r, p, TRUE) |
| R | dnbinom(k, size = r, prob = p) | pnbinom(k, size = r, prob = p) |
| Python (SciPy) | scipy.stats.nbinom.pmf(k, r, p) | scipy.stats.nbinom.cdf(k, r, p) |
All three count failures, not trials, so use the failures convention to compare with them, or enter k − r in their functions when your k counts trials. The TI-84 has no negative binomial function.
Related guides and calculators
The at least one probability calculator covers the chance of a success within n tries, and the hypergeometric distribution is the model when you draw without replacement. The continuous counterpart of the waiting time is the gamma distribution. Read probability distributions and binomial vs Poisson vs hypergeometric to place this one among its neighbors.
Frequently Asked Questions
What is the difference between the trials and failures conventions?
One convention counts every trial up to and including the r-th success (r, r + 1, r + 2, ...), the other counts only the failures before it (0, 1, 2, ...). They describe the same experiment with trials = failures + r. R, SciPy and Excel use the failures form, many textbooks use the trials form, so match the convention before comparing numbers.
How is the negative binomial related to the geometric distribution?
The geometric distribution is the negative binomial with r = 1: it waits for the first success. In general the negative binomial is the sum of r independent geometric waiting times, which is why its mean is r times the geometric mean and its variance is r times the geometric variance.
How is it related to the binomial distribution?
They describe the same trials from two sides. The r-th success occurs on or before trial k exactly when k trials contain at least r successes, so P(X <= k) for the negative binomial equals the binomial probability of r or more successes in k trials. The binomial fixes the trials and counts successes; the negative binomial fixes the successes and counts trials.
Can r be a decimal?
In the failures convention, yes: the distribution is defined for any positive r using the gamma function, and this is how it is fitted to overdispersed count data. In the trials convention r must be a whole number, because the r-th success has to happen on a trial you can count.
Why use the negative binomial instead of the Poisson for counts?
A Poisson variable has variance equal to its mean, but real counts such as visits, claims or defects are often more spread out. The negative binomial adds a dispersion parameter r so that the variance is mu + mu^2/r, and it approaches the Poisson as r grows large. If your observed variance is well above the mean, the negative binomial fits better.
What are the mean and variance?
In the failures convention the mean is r(1 - p)/p and in the trials convention it is r/p. The variance is r(1 - p)/p^2 in both, because shifting by the constant r does not change the spread. The calculator also reports the standard deviation and the skewness.
What limits does the calculator have?
The number of required successes can be up to 1,000,000 and the mean number of failures r(1 - p)/p up to 1,000,000. Within these limits the probabilities have been checked against high-precision arithmetic to at least nine significant digits; larger values are refused with a message instead of being answered with a less accurate number.
Embed This Calculator
Add this free calculator to your course page or LMS.
Adjust the height value to fit your page.