Negative Binomial Distribution Calculator
Calculate negative binomial distribution probabilities for modeling trials or failures needed to achieve r successes. Get PMF, CDF, step-by-step solutions, charts, and trial sequence visualizations.
What is the Negative Binomial Distribution?
The negative binomial distribution is a discrete probability distribution that models the number of failures (or total trials) that occur before a specified number of successes is achieved in a sequence of independent and identically distributed Bernoulli trials. It is a natural extension of the geometric distribution, which models the number of failures before the first success.
The negative binomial distribution is widely used in fields such as quality control (number of defective items before finding r good ones), ecology (capture-recapture studies), epidemiology (number of contacts before r infections), and sports analytics (shots needed to score r goals). It is also commonly used as a robust alternative to the Poisson distribution when the variance exceeds the mean (overdispersion).
Formulas and Parameterizations
The negative binomial distribution has two common parameterizations. Our calculator supports both:
Failures Parameterization (X = number of failures before r-th success)
The probability mass function (PMF) is:
P(X = k) = C(k + r - 1, r - 1) × pr × (1 - p)k
where:
- r = number of successes needed (positive integer)
- p = probability of success on each trial
- k = number of failures observed (k ≥ 0)
- C(n, k) = binomial coefficient = n! / (k! × (n - k)!)
The random variable X can take values k = 0, 1, 2, ...
Trials Parameterization (Y = total number of trials for r-th success)
Using the relationship Y = X + r, the PMF becomes:
P(Y = k) = C(k - 1, r - 1) × pr × (1 - p)k - r
The random variable Y can take values k = r, r+1, r+2, ...
Key Properties
For the failures parameterization (X):
- Mean: E[X] = r(1 - p) / p
- Variance: Var[X] = r(1 - p) / p2
- Standard Deviation: σ = √(r(1 - p) / p2)
- Skewness: (2 - p) / √(r(1 - p))
Special Cases
- When r = 1, the negative binomial distribution reduces to the geometric distribution (number of failures before the first success).
- As r → ∞ and p → 1 while keeping r(1-p) constant, the negative binomial converges to the Poisson distribution.
How to Use the Calculator
- Select Parameterization Mode: Choose between "Failures before r-th success" or "Total trials for r-th success".
- Set Number of Successes (r): Enter the target number of successes (positive integer).
- Set Probability of Success (p): Enter the success probability per trial (0 < p ≤ 1).
- Set k Value: Enter the observed number of failures or total trials depending on the mode.
- View Results: The calculator displays P(X = k), P(X ≤ k), P(X ≥ k), P(X < k), and P(X > k) along with statistical summary, step-by-step solution, distribution table, and PMF chart.
This tool is ideal for students learning probability theory, statisticians performing data analysis, quality engineers, researchers, and anyone working with count data where the number of trials is variable. For related calculations, try our Binomial Probability Distribution Calculator for fixed-number-of-trials scenarios.
Frequently Asked Questions
What is the difference between binomial and negative binomial distributions?
The binomial distribution models the number of successes in a fixed number of trials, while the negative binomial distribution models the number of trials or failures needed to achieve a fixed number of successes. In the binomial, the number of trials is fixed and the number of successes varies; in the negative binomial, the number of successes is fixed and the number of trials varies.
When should I use the failures parameterization vs the trials parameterization?
Use the failures parameterization when you want to model the number of failures before observing r successes. Use the trials parameterization when you want to model the total number of trials (including successes) needed to achieve r successes. The choice depends on your specific application and which variable is more natural to report.
What happens when r = 1?
When r = 1, the negative binomial distribution becomes the geometric distribution, which models the number of failures before the first success. The PMF simplifies to P(X = k) = p(1-p)^k, and the mean becomes (1-p)/p.
Can the negative binomial distribution handle overdispersed count data?
Yes, the negative binomial distribution is commonly used as a robust alternative to the Poisson distribution when count data exhibits overdispersion (variance greater than mean). Unlike the Poisson distribution which assumes equal mean and variance, the negative binomial has an extra parameter that allows it to model data with higher variability.
What are the constraints on the input parameters?
r must be a positive integer (r ≥ 1). p must be between 0 (exclusive) and 1 (inclusive). In the failures mode, k must be a non-negative integer (k ≥ 0). In the trials mode, k must be at least r (k ≥ r). For numerical stability, r is limited to a maximum of 500.
How is the negative binomial used in real-world applications?
Real-world applications include: quality control (number of inspected items until finding r defects), sports analytics (shots needed to score r goals), epidemiology (number of contacts before r infections), ecology (capture-recapture studies), insurance (number of claims until a threshold is reached), and as a regression model for count data with overdispersion.