Negative Binomial Distribution Calculator - PMF, CDF, Mean, and Variance
Use this negative binomial distribution calculator to compute exact and cumulative probabilities, mean, variance, standard deviation, mode, and skewness from r, p, and k.
Negative Binomial Distribution Calculator
Results
What Is Negative Binomial Distribution Calculator?
A negative binomial distribution calculator turns the target success count r, the per-trial success probability p, and the observed failure count k into the exact probability, cumulative probability, survival, and the full set of summary statistics for the discrete distribution of failures before the r-th success in a sequence of independent Bernoulli trials. Use it for quality control lots, sports win streaks, insurance claim counts, and overdispersed count data, then read the PMF, CDF, mean, variance, mode, and skewness from the same three inputs.
- • Quality control inspection: Estimate how many defective items to expect before a target number of good items in a sample, when each draw is independent with constant defect probability.
- • Sports analytics: Model the number of losses a team or player accumulates before reaching a target number of wins in a season of independent games with a stable win rate.
- • Epidemiology and insurance claims: Fit overdispersed count data such as doctor visits, accidents, or claims per period, where the variance is larger than the mean.
- • Variance always exceeds the mean: Because σ² = μ/p with p < 1, the negative binomial distribution is always overdispersed relative to the Poisson distribution with the same mean.
Because the negative binomial distribution fixes the number of successes and counts the failures, the Binomial Distribution Calculator is the natural pair to revisit when the experiment instead fixes the number of trials and counts the successes.
How Negative Binomial Distribution Calculator Works
The calculator reads r, p, and k, builds the exact PMF from the binomial coefficient C(r + k − 1, k) and the powers p^r and (1 − p)^k, then sums the PMF from 0 up to k to produce the cumulative probability and the survival. The summary measures all come from closed-form expressions in r and p alone.
- r: Target number of successes. Positive integer that controls how many successes must be observed before the count stops.
- p: Success probability on each independent Bernoulli trial. Strictly between 0 and 1.
- k: Number of failures observed before the r-th success. Non-negative integer.
- C(r + k − 1, k): Binomial coefficient in the PMF, equal to the number of ways to interleave k failures with r − 1 successes in the first r + k − 1 trials.
- p^r: Probability that the last r trials all succeed and contain the r-th success.
- (1 − p)^k: Probability that exactly k failures occur among the first r + k − 1 trials.
The binomial coefficient is computed with a multiplicative product from i = 1 through k so the calculation stays accurate for k as large as 10 000 without overflowing.
Standard case r = 3, p = 0.5, k = 2
r = 3, p = 0.5, k = 2.
C(4, 2) · 0.5^3 · 0.5^2 = 6 · 0.125 · 0.25 = 0.1875. CDF = P(X ≤ 2) = 0.125 + 0.1875 + 0.1875 = 0.5.
PMF = 0.1875, CDF = 0.5, mean = 3, variance = 6, standard deviation ≈ 2.4495, mode = 2, skewness ≈ 1.2247.
The PMF and CDF match the textbook answer for flipping a fair coin until the third head and asking for the probability of exactly two tails, and the variance exceeding the mean by a factor of two is the fingerprint of overdispersion.
According to Wolfram MathWorld's Negative Binomial Distribution entry, the distribution (also called the Pascal or Pólya distribution) gives the probability of r − 1 successes and k failures in r + k − 1 trials with success on the (r + k)th trial, with PMF C(r + k − 1, k) p^r (1 − p)^k, mean r(1 − p)/p, variance r(1 − p)/p², skewness (2 − p)/√(r(1 − p)), and collapses to the geometric distribution when r = 1.
When r = 1 the negative binomial distribution collapses to the geometric distribution, so the Geometric Distribution Calculator is the right sanity check for any single-success waiting-time problem you model here.
Key Concepts Explained
Four ideas separate a negative binomial calculation from a black-box probability and let the user interpret the result on real data.
Target successes, not trials
The negative binomial distribution fixes the number of successes r and counts the failures, the opposite of the binomial distribution, which fixes the number of trials and counts the successes.
r controls the peak, p controls the spread
Increasing r shifts the mean up by (1 − p)/p and inflates the variance by (1 − p)/p². Decreasing p pushes both up sharply.
Geometric is the r = 1 case
When r = 1 the distribution is the geometric distribution: P(X = k) = p (1 − p)^k, mean (1 − p)/p, mode 0. The same calculator with r = 1 then models waiting time to a single success.
Variance always exceeds the mean
Because σ² = μ/p and p is strictly less than 1, the negative binomial distribution is always overdispersed relative to the Poisson distribution with the same mean.
These four ideas are also why the negative binomial distribution is the right tool for overdispersed count data that the Poisson distribution cannot fit cleanly.
Because the negative binomial distribution is overdispersed relative to a Poisson count, the Poisson Distribution Calculator is the natural baseline to compare against whenever you want to see how much extra spread the negative binomial adds.
How to Use This Calculator
Enter the target successes r, the success probability p, and the failure count k to read the exact probability, cumulative probability, and summary measures in one panel.
- 1 Set the target successes r: Type a positive integer for the number of successes you need before the count stops. r = 1 reduces the distribution to the geometric distribution.
- 2 Set the success probability p: Type the per-trial success probability strictly between 0 and 1. The calculator rejects p ≤ 0 or p ≥ 1 with a clear validation error.
- 3 Enter the failure count k: Type the observed number of failures before the r-th success. k = 0 means the first r trials were all successes.
- 4 Read the exact and cumulative probabilities: The PMF, CDF, survival, and the two strict-comparison probabilities update from r, p, and k automatically.
- 5 Read the summary measures: The mean, variance, standard deviation, mode, and skewness update from r and p alone, so changing only k does not affect them.
- 6 Reset to defaults: Press reset to return r, p, and k to 3, 0.5, and 2.
Suppose r = 3, p = 0.5, and k = 2. The PMF is 0.1875, the CDF is 0.5, the mean is 3, the variance is 6, and the mode is 2, with the variance being twice the mean as the visual fingerprint of an overdispersed count.
When you want to compare the observed failure count with the distribution's mean and standard deviation, the Z-Score Calculator returns the standardized score that lets you judge how unusual the observation is.
Benefits of Using This Calculator
An all-in-one negative binomial distribution calculator removes the need to switch between separate PMF, CDF, mean, and variance tools.
- • Exact and cumulative probabilities from the same inputs: Read P(X = k), P(X ≤ k), P(X ≥ k), P(X > k), and P(X < k) from one set of r, p, and k inputs without re-typing values.
- • Closed-form summary measures: Read the mean, variance, standard deviation, mode, and skewness from r and p alone, with no additional assumptions.
- • Auditable binomial coefficient: Display C(r + k − 1, k) alongside the PMF so the user can verify the combinatorial count by hand.
- • Geometric reduction for r = 1: Setting r = 1 turns the calculator into a geometric distribution calculator with the same closed-form formulas.
- • Strict input validation: Out-of-range r, p, and k are rejected with clear error messages so silent overflow or degenerate distributions do not slip through.
The benefit is that the negative binomial distribution has closed-form formulas for every question a course or analyst is likely to ask, so a single deterministic calculator covers the whole workflow.
For continuous waiting-time problems with a constant rate λ, the Exponential Distribution Calculator is the continuous analogue of the geometric and negative binomial waiting-time families.
Factors That Affect Your Results
The shape of every output changes with r and p, and a few practical caveats apply when the underlying assumptions do not hold.
r sets the location of the distribution
Increasing r by 1 adds (1 − p)/p to the mean and adds (1 − p)/p² to the variance, so r shifts the whole distribution to the right while preserving the skewness shape.
p controls the mean and the variance jointly
Both μ = r(1 − p)/p and σ² = r(1 − p)/p² diverge as p → 0, so a smaller p produces a heavier-tailed distribution with much larger spread.
k must be a non-negative integer
Negative or fractional k is rejected because the negative binomial distribution is defined on the non-negative integers only.
Geometric boundary when r = 1
When r = 1 the mode is 0, the variance equals μ/p, and the PMF is monotone decreasing in k. Use the same calculator with r = 1 to model waiting time to a single success.
- • The calculator does not fit r and p from a sample, run a goodness-of-fit test, or simulate datasets.
- • The formulas assume independent Bernoulli trials with constant success probability p, so a drifting per-trial probability may not match the closed-form negative binomial.
- • For very small p the variance and skewness become very large, so floating-point precision can degrade for k larger than a few hundred failures.
Read the variance and the mean together whenever the result is sensitive to overdispersion. A variance much larger than the mean is the visual fingerprint of negative binomial data.
According to the Wikipedia article on the negative binomial distribution, the distribution is a gamma-Poisson mixture with variance μ/p and the standard overdispersed alternative to the Poisson distribution in regression and epidemiology.
According to the NIST Engineering Statistics Handbook entry on the Binomial Distribution, both the binomial and the negative binomial distribution rely on independent Bernoulli trials with constant success probability p, so the negative binomial inherits the same independence and constant-probability assumptions from the Bernoulli trial model.
Frequently Asked Questions
Q: What is a negative binomial distribution and when is it used?
A: A negative binomial distribution models the number of failures observed before the r-th success in a sequence of independent Bernoulli trials with constant success probability p. It is used for overdispersed count data in epidemiology, insurance, and reliability, and for waiting-time problems such as the number of defective items before a quality-control target or the number of losses before a target win count.
Q: How do I calculate the probability P(X = k) for a negative binomial distribution?
A: Use P(X = k) = C(r + k − 1, k) · p^r · (1 − p)^k. The binomial coefficient counts the ways to interleave k failures with r − 1 successes in the first r + k − 1 trials, p^r is the probability that all r successes occur in the sequence (each success has independent probability p, with the r-th success forced to be the final trial), and (1 − p)^k is the probability that the k failures occur among the first r + k − 1 trials.
Q: What is the formula for the mean and variance of a negative binomial distribution?
A: The mean is r(1 − p)/p and the variance is r(1 − p)/p². The standard deviation is √(r(1 − p))/p. Because the variance is always larger than the mean when p is less than 1, the negative binomial distribution is overdispersed relative to the Poisson distribution with the same mean.
Q: What is the difference between the binomial and the negative binomial distribution?
A: The binomial distribution fixes the number of trials n and counts the successes, while the negative binomial distribution fixes the number of successes r and counts the failures before that r-th success. The two distributions are not the same family: the binomial parameter n is bounded above by the trial budget, while the negative binomial parameter r is a free choice with the failure count unbounded.
Q: What is the relationship between the negative binomial and the geometric distribution?
A: The geometric distribution is the negative binomial distribution with r = 1. Setting r = 1 in the calculator turns the model into a waiting-time-to-first-success problem with PMF p (1 − p)^k, mean (1 − p)/p, and variance (1 − p)/p², and a mode of 0.
Q: How do I find the mode and skewness of a negative binomial distribution?
A: The mode is floor((r − 1)(1 − p)/p) for r > 1 and 0 for r = 1. The skewness is (2 − p)/√(r(1 − p)). Both are pure numbers because the failure count is dimensionless, and the skewness is always positive because the distribution has a long right tail.