Interactive module guide
Negative Binomial Distribution Calculator & Guide
This negative binomial distribution calculator lets you calculate probabilities for the failures before a target number of successes and explore overdispersed counts.
Free · No sign-up · Calculations stay in your browser
The negative binomial distribution models the number of failures observed before the r-th success in a sequence of independent Bernoulli trials with success probability p, so its support starts at zero.
Its mean is r(1−p)/p and its variance r(1−p)/p² always exceeds that mean, which gives the family its second life as the standard model for overdispersed count data that a Poisson model cannot represent.
This page uses the failures convention; sources that count total trials until the r-th success shift every value up by r, so confirm the convention before comparing numbers.
Is this the right module for my question?
Use it when
- Use it for stopping-rule questions: how many failures accumulate before a target number of successes is reached, such as defective units produced before five conforming ones, or unsuccessful contacts before a quota of interviews is filled.
- Use it for count data whose variance clearly exceeds the mean. A Poisson model forces equality of the two; the negative binomial arises as a Poisson model whose rate itself varies according to a gamma distribution, so clustered or heterogeneous event counts—insurance claims, sequencing reads, accident tallies—are its home ground.
- Use the quantile lookup for planning with uncertainty: the smallest failure count k whose cumulative probability reaches 0.95 bounds the resources wasted before the r-th success with stated assurance.
Choose another method when
- Avoid it when trials are not independent with constant p. A production process that drifts, or contacts drawn from a shrinking pool, changes p across trials and breaks the stopping-rule derivation.
- Avoid forcing it onto counts whose variance is close to or below the mean. Equidispersed counts are what the Poisson model is for, and underdispersed counts need different machinery entirely; fitting a negative binomial there wastes a parameter and destabilizes estimates.
- Avoid it for the special case questions other pages answer directly: r=1 waiting questions belong to the geometric page, and fixed-trial-count success questions belong to the binomial page.
Interactive tool
The calculator loads as you approach this section so the guide remains fast on mobile connections.
Example preview
Defects before the fifth success
- Inputs
- X ~ NegBin(r=5, p=0.4), failures before the 5th success; evaluate at most 4 failures.
- Representative result
- P(X≤4) ≈ 0.2666, summing the first five mass values.
Illustrative only. Load the interactive tool to enter your own values and review assumptions.
Watch the explanation
3:08 minThe player loads only after you press play. You can also watch on YouTube.
Read the complete transcript
The Negative Binomial Distribution. How many failures accumulate before a process finally reaches its required number of successes? This page counts failures before success number r, so the support begins at zero. For X equal k, the final trial is success r, while earlier outcomes can be rearranged. That combinatorial count multiplies r success factors and k failure factors to form the mass. Zero failures means r immediate successes, while r equals one recovers a geometric wait. Sources counting total trials add r to every failure count, shifting location but not spread.
The point masses rise toward a mode, then trail gradually across the unbounded integer support. Mean is r times one minus p over p; variance adds another division by p. Their ratio is one over p, exceeding the Poisson ratio whenever the model is nondegenerate. The mode has a closed form, while the median is found as an exact integer quantile. Positive skewness and excess kurtosis quantify the long upper tail, both shrinking as r grows. At fixed p, larger r shifts the sum rightward and makes its standardized shape more symmetric. At fixed mean, smaller r creates greater extra-Poisson variance and a heavier planning tail.
Suppose conforming probability is point four, independently, and production stops after five conforming units. Finishing with zero defects requires five immediate conforming units, with probability point four to the fifth. The masses climb from point zero one zero two four toward equal peaks at five and six. Summing through four defects gives about point two six six six, only roughly one quarter. Mean defects are seven point five, variance eighteen point seven five, and standard deviation four point three three. Six is a mode, seven is the median, and the ninety-five-percent planning bound is sixteen.
A Poisson count with the same mean is far narrower because its variance must equal its mean. Mixing Poisson rates with gamma heterogeneity produces the negative binomial and explains clustered counts. The same mathematics supports a stopping-rule story and a heterogeneous-count story, with different assumptions. For the stopping story, dependence or changing success probability breaks the negative-binomial derivation. Counts near or below Poisson variance need another model, not an unnecessary dispersion parameter. The explorer evaluates specified r and p; fitting data needs model comparison and uncertainty analysis. Inspect residuals by count and zero frequency, because matched variance alone does not guarantee fit. Report the convention, mechanism, parameter source, exact event, and probability or quantile requested. Explore negative-binomial masses, tails, and planning quantiles free at Distri Scope dot com.
How to read the result
The chart shifts right and becomes more symmetric as r grows at fixed p: sums of r independent geometric-type waits smooth out, a small central-limit effect visible directly in the bars.
The variance-to-mean ratio 1/p is a quick diagnostic to read from the summary: at p=0.4 the variance is 2.5 times the mean, far beyond anything a Poisson model can express.
Skewness falls like 1/√r, so heavy asymmetry in a fitted negative binomial signals a small effective r—strong clustering—rather than a large one.
Inputs and parameter meaning
Two parameters: the required number of successes r, an integer from 1 to 50 here, and the per-trial success probability p from 0.05 to 0.99. The displayed support runs from zero to the 99.9th percentile.
This page counts failures before the r-th success, so the value zero means the first r trials were all successes, with probability p^r. Trials-convention sources report k+r where this page reports k.
In the overdispersion interpretation, smaller r means stronger clustering: the variance-to-mean ratio is 1/p, and r controls how heavy the upper tail is at a fixed mean.
Formula and available parameters
Density or probability mass
Mean
Variance
- Required successes (r): interactive range 1 to 50; default 5.
- Probability of success (p): interactive range 0.05 to 0.99; default 0.4.
What the method is doing
The mass function is evaluated through logarithms of gamma functions rather than raw binomial coefficients, so large counts do not overflow, and the CDF uses the exact identity linking the negative binomial to the regularized incomplete beta function rather than term-by-term summation.
Quantiles are exact: a search finds the smallest integer whose cumulative probability reaches the requested level, and the summary median is that quantile at one half.
Closed-form moments are reported: mean r(1−p)/p, variance r(1−p)/p², skewness (2−p)/√(r(1−p)), and excess kurtosis 6/r+p²/(r(1−p)). For r above one the mode is ⌊(r−1)(1−p)/p⌋; for r=1 it is zero, matching the geometric shape.
Worked example: defects before the fifth conforming unit
A line produces conforming units with probability p=0.4 per attempt, independently. Production continues until r=5 conforming units are collected, and the engineer wants the distribution of defective units produced along the way: the chance of at most 4 defects, the expected number of defects, and a 95% planning bound. Model the defect count as X~NegBin(r=5, p=0.4) on the failures convention.
- 1Read the cumulative value at 4: P(X≤4)≈0.2666, so only about a quarter of runs finish with four or fewer defects.
- 2Read the summary: the mean is 5×0.6/0.4=7.5 defects and the standard deviation is √18.75≈4.33, an overdispersed spread with variance 2.5 times the mean.
- 3Use the quantile lookup: the 95th percentile is 16, so planning for sixteen defects covers all but the unluckiest 5% of runs; the median 7 sits below the mean, showing the right skew.
- 4Check the mode ⌊(5−1)×0.6/0.4⌋=⌊6⌋=6: the single most likely defect count is six, close to but below the mean, as expected for a right-skewed count.
Interpretation
Under the stated model a typical run produces about seven defects before the fifth conforming unit, but the 95% bound of sixteen is more than twice the mean. That gap is the practical cost of overdispersion: budgeting on the average alone would fail roughly half the runs, and the tail—not the center—should drive the resource plan.
Common mistakes
- Do not mix the failures and trials conventions. This page reports failures; adding the r successes converts to total trials, and every mean, median, and quantile shifts by exactly r between the two.
- Do not read overdispersion as a defect of the data. Variance above the mean is information—evidence of heterogeneity or clustering—and the gamma-mixed-Poisson view of the negative binomial models it explicitly rather than averaging it away.
- Do not compare a fitted negative binomial with a Poisson model on likelihood alone without noting the extra parameter; the negative binomial can never fit worse, so an information criterion or a formal dispersion test is the honest comparison.
Limits and independent validation
The page assumes known r and p; it does not estimate them from data. Fitting count data, including the dispersion parameter, is a data-fitting task with its own diagnostics.
r is restricted to integers here, matching the stopping-rule story. The overdispersion literature allows real-valued r; conclusions drawn from integer r transfer, but exact fitted values from other software may be non-integer.
Very small p with large r produces long supports; the display truncates at the 99.9th percentile while the underlying CDF remains exact, so visible bars intentionally omit a 0.1% tail.
Before using the result
- Justify independence and constant p from the mechanism before using the stopping-rule reading, exactly as for the geometric model; for the overdispersion reading, verify variance above mean in the data before reaching for the family at all.
- Recompute one mass by hand for small counts: P(X=0)=p^r, so r=5 and p=0.4 must give 0.4⁵=0.01024. A mismatch signals a convention or entry error.
- When fitting real counts, compare negative binomial and Poisson fits with an information criterion and inspect residuals by count value; a good dispersion match with poor zero-count fit suggests zero inflation instead.
Related modules and resources
Explore Other Probability Distributions
- Normal Distribution Calculator
- Binomial Distribution Calculator
- Poisson Distribution Calculator
- Exponential Distribution Calculator
- Gamma Distribution Calculator
- Beta Distribution Calculator
- Weibull Distribution Calculator
- Lognormal Distribution Calculator
- Continuous Uniform Distribution
- Student’s t Distribution
- Chi-Square Distribution
- F Distribution
- Bernoulli Distribution
- Geometric Distribution
- Negative Binomial Distribution
- Hypergeometric Distribution
- Cauchy Distribution
- Pareto Distribution
- Laplace Distribution
- Logistic Distribution
- Rayleigh Distribution
- Triangular Distribution
- Discrete Uniform Distribution
See every option in the Probability Distribution Explorer or review the DistriScope methodology. Educational information; last reviewed 2026-08-09. Verify consequential calculations independently.