Negative Binomial Distribution Calculator

Find negative binomial probabilities, mean, variance, and a full distribution table for any r, p, and k.

🎲 Negative Binomial Distribution Calculator
Successes Needed (r)3
120
Success Probability per Trial (%)30
%
1%100%
Trial Number (k)10
1100
Successes Needed (r)3
120
Success Probability per Trial (%)30
%
1%100%
Maximum Trial Number20
250
P(X = k)
P(X ≤ k)
P(X ≥ k)
Mean (r ÷ p)
Variance
Std Deviation
Mean (r ÷ p)
Std Deviation

🎲 What is the Negative Binomial Distribution?

The negative binomial distribution is a discrete probability distribution that models the number of trials needed to achieve a fixed number of successes in a sequence of independent Bernoulli trials. Each trial has the same probability p of success. If X is the trial number on which the r-th success occurs, then X follows a Negative Binomial(r, p) distribution with possible values X = r, r+1, r+2, ... The minimum value is r because you need at least r trials to accumulate r successes.

This distribution has wide practical applications. In clinical trials, researchers model the number of patients to screen until r eligible participants are enrolled. In quality control, inspectors track how many items must be checked before finding r defectives. In sales and marketing, teams calculate how many customer contacts are needed before closing r sales. In network engineering, the negative binomial models the number of packet transmissions required until r successful acknowledgements are received. In ecology, it captures the overdispersed distribution of animal counts in quadrats, where variance exceeds the mean.

A common point of confusion is the relationship between the negative binomial and the binomial distribution. The binomial counts successes in a fixed number of trials; the negative binomial counts trials until a fixed number of successes. They are complementary perspectives on the same underlying Bernoulli process. Another important relationship: the geometric distribution is the special case of the negative binomial with r = 1, modeling the number of trials until the very first success.

The negative binomial is also used in statistics and data science to model count data with overdispersion, where the variance of observed counts exceeds what the Poisson distribution would predict. This makes it a common choice for regression models on count outcomes such as website visits, hospital admissions, or accident frequencies where true Poisson behavior is too restrictive.

📐 Formula

P(X = k)  =  C(k−1, r−1) × pr × (1−p)k−r
X = trial number on which the r-th success occurs (X = r, r+1, r+2, ...)
k = specific trial number (integer ≥ r)
r = number of successes needed (positive integer)
p = probability of success on each trial (0 < p ≤ 1)
C(k−1, r−1) = binomial coefficient = (k−1)! ÷ [(r−1)! × (k−r)!]
Example: r = 3, p = 0.30, k = 10: C(9,2) × 0.33 × 0.77 = 36 × 0.027 × 0.08235 = 0.0800 (8.00%)
Mean  =  r ÷ p     Variance  =  r(1−p) ÷ p²
Mean = expected trial count to get r successes
Variance = spread around the mean; standard deviation = √[r(1−p)/p²]
Example: r = 3, p = 0.30: Mean = 3/0.30 = 10 trials; Variance = 3 × 0.70 / 0.09 = 23.33; SD ≈ 4.83

📖 How to Use This Calculator

Steps

1
Enter successes needed r and probability p - Set r to the number of successes you want to observe and enter p as the per-trial success probability percentage. For example, r = 3 and p = 30% models waiting for 3 successes when each trial has a 30% chance of success.
2
Enter the trial number k - Set k to the specific trial number you want to compute P(X = k) for. k must be at least r since you need at least r trials to achieve r successes. For example, with r = 3, k must be 3 or higher.
3
Read the probabilities and distribution statistics - The calculator shows P(X = k) (exact), P(X at most k) (cumulative), P(X at least k) (upper tail), plus the mean r/p, variance, and standard deviation. Switch to Distribution Table mode to see the full PMF and CDF for all trial numbers from r to your chosen maximum.

💡 Example Calculations

Example 1 - Basketball Free Throws: 5 Makes from 8 Attempts

A player makes 70% of free throws. What is the probability the 5th make occurs on exactly the 8th attempt?

1
Set r = 5 (makes needed), p = 70%, k = 8 (attempt number). This asks: what is P(X = 8)?
2
Apply the formula: P(X = 8) = C(7, 4) × 0.705 × 0.303 = 35 × 0.16807 × 0.027 = 0.1588.
3
The mean is r/p = 5/0.70 ≈ 7.14 attempts. So 8 attempts is slightly above average.
P(5th make on 8th attempt) = 15.88%
Try this example →

Example 2 - Quality Control: Finding 3 Defects in 10 Items

A factory produces items with a 20% defect rate. What is P(3rd defect is found on the 10th item)?

1
Set r = 3 (defects to find), p = 20% (defect rate), k = 10. We want P(X = 10).
2
P(X = 10) = C(9, 2) × 0.203 × 0.807 = 36 × 0.008 × 0.2097 = 0.0604.
3
The mean is 3/0.20 = 15 items on average to find 3 defects, so finding the 3rd defect by item 10 would be faster than average.
P(3rd defect on item 10) = 6.04%
Try this example →

Example 3 - Clinical Trial: 10 Responders from 30 Screened

A drug has a 40% response rate. What is the probability the 10th responder is found on exactly the 30th patient screened?

1
Set r = 10 (responders needed), p = 40%, k = 30. The mean is 10/0.40 = 25 patients expected.
2
P(X = 30) = C(29, 9) × 0.4010 × 0.6020. Using log-space: log P ≈ −3.261, so P ≈ 0.0381.
3
30 patients is above the mean of 25. P(X at most 30) ≈ 85.6%, meaning there is an 85.6% chance the 10th responder is found within the first 30 patients.
P(10th responder on patient 30) = 3.81%
Try this example →

❓ Frequently Asked Questions

What is the negative binomial distribution formula?+
The negative binomial PMF is P(X = k) = C(k-1, r-1) times p^r times (1-p)^(k-r) for k = r, r+1, r+2, ... where k is the trial number of the r-th success, r is the number of successes needed, and p is the per-trial success probability. C(k-1, r-1) is the binomial coefficient counting ways to arrange r-1 successes among the first k-1 trials, with the k-th trial always being a success.
What is the mean and variance of the negative binomial distribution?+
The mean is mu = r/p and the variance is sigma^2 = r(1-p)/p^2. The standard deviation is sigma = sqrt(r(1-p)/p^2). For r = 3, p = 0.30: mean = 10 trials, variance = 23.33, SD = 4.83. The variance always exceeds the mean (since variance/mean = (1-p)/p which is greater than 1 when p is less than 0.5), making the negative binomial more spread out than a Poisson with the same mean.
How is the negative binomial different from the binomial distribution?+
In the binomial distribution B(n, p), the number of trials n is fixed and the number of successes X is random. In the negative binomial NB(r, p), the number of successes r is fixed and the number of trials X is random. Binomial answers "how many successes in n trials?" while negative binomial answers "how many trials until r successes?" They are complementary views of the same Bernoulli process.
How is the negative binomial related to the geometric distribution?+
The geometric distribution is the special case of the negative binomial with r = 1. With r = 1, P(X = k) = C(k-1, 0) times p times (1-p)^(k-1) = p(1-p)^(k-1), which is exactly the geometric PMF. The geometric models trials until the first success; the negative binomial generalizes this to trials until the r-th success. Set r = 1 in this calculator to get geometric probabilities.
What is the cumulative distribution function (CDF) of the negative binomial?+
P(X at most k) = sum of P(X = j) for j from r to k. There is no simple closed form, so the CDF is computed by summing PMF values. The upper tail P(X at least k) = 1 - P(X at most k-1). The CDF can also be expressed in terms of the regularized incomplete beta function, but for practical calculation, summing PMF values (as this calculator does) is the most straightforward approach.
Why is the distribution called "negative binomial"?+
The name comes from the generalized binomial series: (1-x)^(-r) = sum over k=0 to infinity of C(r+k-1, k) x^k. The PMF of the negative binomial (in the failures-before-r-th-success parameterization) matches the terms of this series with x = 1-p. The "negative" refers to the negative exponent -r in the binomial expansion, distinguishing it from the ordinary binomial (1+x)^n with a positive exponent.
What is the difference between P(X = k) and P(X at most k)?+
P(X = k) is the exact probability the r-th success occurs on trial k, a specific point probability. P(X at most k) is the cumulative probability the r-th success occurs by trial k, summing all probabilities from k = r up to the specific k. P(X at most k) is useful for questions like "what is the chance we achieve r successes within k trials?" while P(X = k) answers "what is the chance it takes exactly k trials?"
Can I use the negative binomial to model overdispersed count data?+
Yes. The negative binomial regression model is commonly used for count outcomes where variance exceeds the mean (overdispersion). In this context, the distribution is parameterized differently: as a Poisson-gamma mixture where the Poisson rate itself follows a gamma distribution. The r parameter becomes the "size" or "dispersion" parameter. Common applications include modelling insurance claims, hospital re-admissions, accident counts, and website visits per user.
What is the maximum likelihood estimate of p in the negative binomial?+
If you observe x_1, x_2, ..., x_n independent negative binomial trials each with the same r successes needed, the MLE of p is p-hat = r / x-bar, where x-bar is the sample mean of the observed trial counts. This follows from differentiating the log-likelihood and setting it to zero. The MLE of r is more complex and usually requires numerical optimization.
What are the assumptions of the negative binomial distribution?+
The negative binomial requires: (1) each trial results in exactly one of two outcomes (success or failure), (2) trials are independent, (3) the probability of success p is constant on every trial, and (4) the experiment continues until exactly r successes are observed. Violations of these assumptions (changing p over time, correlated trials, unknown stopping rule) invalidate the model. Real-world applications should verify these conditions before using the negative binomial.
How does increasing r affect the negative binomial distribution?+
Increasing r shifts the distribution to the right (higher mean) and makes it more bell-shaped. Mean = r/p grows linearly with r. Standard deviation = sqrt(r(1-p)/p^2) grows as sqrt(r), so the coefficient of variation (SD/mean) = sqrt((1-p)/r)/p decreases. As r approaches infinity, the normalized negative binomial converges to a normal distribution by the central limit theorem. The distribution becomes more symmetric and concentrated around the mean.
How does this calculator compute probabilities for large k and r?+
The calculator uses log-space computation to avoid floating-point overflow. The binomial coefficient C(k-1, r-1) is computed as exp(logGamma(k) - logGamma(r) - logGamma(k-r+1)) using the Lanczos approximation for the log-gamma function. The full log-PMF is log C(k-1,r-1) + r log(p) + (k-r) log(1-p), then exponentiated. This handles combinations involving thousands-sized k and r without overflow errors.