Updated Math

Negative Binomial Calculator

Calculate negative binomial PMF, CDF, tail and range probabilities, quantiles, and summary statistics for failures or trials parameterizations.

PMF CDF Quantiles Mean & Variance

Negative Binomial Probability & Quantile Estimator

Compute exact probabilities, cumulative chances, quantiles, and exportable tables for the negative binomial distribution.

What the Negative Binomial Distribution Measures

The Negative Binomial Distribution is a probability model for repeated independent trials when the process stops after a fixed number of successes. Unlike the binomial distribution, which asks “How many successes happen in a fixed number of trials?”, the negative binomial asks “How many trials (or failures) occur until we reach r successes?” This “stop when we hit a success target” framing is common in real life: you retry an operation until it works a set number of times, you keep calling customers until you close a fixed number of sales, or you keep manufacturing units until you produce a fixed number of items that pass inspection.

Because the stopping rule is based on successes, the distribution naturally captures the uncertainty in how long something takes. Even when the chance of success per attempt is stable, randomness can produce shorter or longer runs. The negative binomial helps you quantify these outcomes with exact probabilities (PMF), cumulative probabilities (CDF), tail chances, and planning thresholds (quantiles). This calculator supports both major ways the distribution is defined: as the number of failures before r successes, or as the number of total trials required to reach r successes.

Understanding the Parameters r and p

The distribution is driven by two values: r and p. The parameter r is the number of successes you require before stopping. It must be a positive integer. The parameter p is the probability that any single trial is a success, and it must lie between 0 and 1. Each trial is assumed to be independent and identically distributed, which means the chance of success does not change from one attempt to the next and outcomes do not influence each other.

In many applied settings, p is estimated from historical data, pilot runs, or domain knowledge. When p is larger, successes happen more often, so you typically need fewer failures and fewer total trials to reach r successes. When p is smaller, the process takes longer on average and also becomes more variable.

Two Common Definitions: Failures vs. Trials

One reason negative binomial calculations can be confusing is that different textbooks and software packages define the random variable differently. The two most common definitions are:

  • Failures before r successes: X counts how many failures occur before the r-th success happens.
  • Trials to reach r successes: X counts the total number of trials needed to achieve r successes.

These are closely related. If Xfail is failures before r successes, then Xtrial = Xfail + r, because r successes are included in the total trials count. This calculator lets you choose the parameterization explicitly, which helps you match results with other tools.

Negative Binomial PMF: Exact Probability of a Specific x

The probability mass function gives the probability of seeing exactly x under the chosen definition. For the “failures before r successes” definition, if x = k failures, the PMF is:

PMF for failures k before r successes
P(X=k) = C(k+r−1, k) · (1−p)k · pr

The binomial coefficient C(k+r−1, k) counts how many sequences of k failures and r successes end with the r-th success on the final trial. The term (1−p)k is the probability of the failures, and pr is the probability of the successes. In the “trials to reach r successes” definition, you typically set n = total trials with n ≥ r and convert k = n − r.

PMF values are useful for “exactly” questions: exactly 6 failures before 5 successes, exactly 12 trials to obtain 5 successes, and similar. The PMF tab is optimized for quick evaluation and also reports the distribution’s mean, variance, and standard deviation for the same parameters.

CDF and Range Probabilities for Planning

The cumulative distribution function (CDF) answers a different question: what is the probability that the statistic is less than or equal to a cutoff? For failures, it is P(X ≤ k). For trials, it is P(X ≤ n). CDF values are useful for planning and service levels. For example:

  • What is the probability we need at most 10 failures to hit 5 successes?
  • What is the probability we finish within 25 trials?
  • What is the chance the outcome falls between two bounds?

The Probability tab includes three common formats: P(X ≤ x), P(X ≥ x), and P(a ≤ X ≤ b). Range probabilities are useful in quality control and operational constraints where both lower and upper bounds matter.

Mean, Variance, and What They Tell You

Summary statistics help you understand the “typical” outcome and how widely outcomes vary. Under the failures parameterization, the expected number of failures before r successes is:

Mean and variance for failures definition
Mean = r(1−p)/p
Variance = r(1−p)/p2

Under the trials parameterization, you add r to the expected failures, so the mean becomes r/p, while the variance remains r(1−p)/p²:

Mean and variance for trials definition
Mean = r/p
Variance = r(1−p)/p2

A practical way to interpret these: if p is small, the expected number of trials grows quickly, and variability also grows. That means planning only around the mean may be risky. Quantiles and tail probabilities are often more useful when you need guarantees like “95% of the time we finish by x.”

Quantiles: Converting Probability Targets into Thresholds

A quantile solves the inverse problem: given a probability level q, find the smallest x such that P(X ≤ x) ≥ q. Quantiles are used in capacity planning, time budgeting, and operational “worst-case within a confidence level” decisions. For example, you might ask:

  • How many trials should we budget so that we succeed at least r times with 95% confidence?
  • How many failures are we likely to see before r successes in 99% of runs?

The Quantile tab computes this threshold by accumulating probabilities until the target q is reached. Because the distribution can have a long tail when p is low, the tool includes a maximum search limit so you can control runtime and ensure the result is meaningful for your context.

Common Use Cases for the Negative Binomial Model

Negative binomial calculations appear in many fields. In sales and marketing, you might model the number of calls required to close a fixed number of deals. In engineering and reliability, you might model the number of attempts required to achieve a fixed number of successful operations. In quality control, you may be interested in how many failures occur before producing a fixed number of passing units. In experiments and A/B testing, the model can reflect “keep running until we collect r conversions” when conversion probability is stable.

The key requirement is the same: independent trials, stable success probability, and a stopping rule based on reaching r successes. When these conditions hold, the negative binomial provides a clean and interpretable model with exact probabilities.

How This Calculator Builds Tables and Exports CSV

Many users need more than one number. Tables provide a practical way to understand the distribution’s shape. The Distribution Table tab creates a row-by-row list of PMF and CDF values across an x range, using your selected parameterization. It also repeats mean and variance so the table can be used as a standalone dataset.

Exporting to CSV makes it easy to analyze the distribution in spreadsheets, build charts, compute cumulative thresholds, and integrate the numbers into reports. This is especially useful when you want to compare multiple parameter sets or present probability budgets to stakeholders.

Assumptions and Interpretation Notes

The negative binomial assumes each trial has the same success probability p and trials are independent. If p changes over time (learning effects, fatigue, shifting market), the model may not match reality. In those cases, you can still use this tool as a baseline scenario by testing multiple p values. If outcomes are correlated (one failure affects the next attempt’s probability), results can also diverge from the model.

Another common source of confusion is definition mismatch: some references define the random variable as failures, others as trials. This tool makes the choice explicit so you can align with your textbook, course, or software package and avoid off-by-r mistakes.

FAQ

Negative Binomial Calculator – Frequently Asked Questions

Answers about r and p, failures vs trials definitions, PMF and CDF interpretation, quantiles, and exports.

The negative binomial distribution models the number of failures before achieving a fixed number of successes in independent Bernoulli trials with constant success probability. A common alternative parameterization models the number of trials needed to reach a set number of successes.

Use a negative binomial model when the stopping rule is “keep trying until we get r successes.” A binomial model uses a fixed number of trials n and counts the number of successes within those n trials.

r is the required number of successes and p is the probability of success per trial. The distribution then describes how many failures (or total trials) it typically takes to achieve r successes.

For failures k before r successes: P(X=k)=C(k+r−1,k)·(1−p)^k·p^r for k=0,1,2,… where C(·) is a binomial coefficient.

For failures parameterization, mean = r(1−p)/p and variance = r(1−p)/p^2. For trials-to-r-successes, mean = r/p and variance = r(1−p)/p^2.

Use the Probability tab. Choose the statistic type (failures or trials), select the probability type (≤, ≥, or between), and enter the cutoff(s). The calculator returns the cumulative or range probability.

A quantile is the smallest x such that P(X ≤ x) is at least a chosen probability q (like 0.95). Quantiles are useful for planning thresholds and worst-case budgeting.

Yes. Build a PMF/CDF table over a range of x values in the Distribution Table tab and export it as a CSV file for spreadsheet analysis.

Some tools define X as failures before r successes, while others define X as total trials to reach r successes. If you switch the calculator’s parameterization to match, results should align.

Results are based on the standard negative binomial model with independent trials and constant success probability. Match the parameterization (failures vs trials) when comparing results to other tools.