Advertisement
Advertisement
PROBABILITY

Negative Binomial Distribution Calculator — waiting for the rth success

Find the probability that the rth success arrives on a given trial, with the cumulative tails, the mean and the variance, in either of the two standard parameterisations.

How many successes you are waiting for. Setting this to 1 reduces the distribution to the geometric case.
Must be the same on every trial, and trials must be independent. Enter it as a decimal between 0 and 1.
Read as a trial number or as a failure count depending on the convention selected below.
Two conventions are in common use and they shift the distribution by exactly r. Textbooks differ; check which one yours means.
Probability of exactly this value
0
 
0
P(X ≤ k)
0
P(X ≥ k)
0
Mean
0
Standard deviation
Working:
Tip: the distribution is right-skewed and stays that way. The mean sits above the mode, so the most likely single outcome is always earlier than the average wait.
Advertisement

The negative binomial distribution calculator above answers a waiting-time question: if each independent trial succeeds with probability p, how likely is it that the rth success arrives exactly on trial k? It reports that probability, both cumulative tails, the mean and the variance, and it does so in whichever of the two standard parameterisations you select.

Arb Digital publishes it because this distribution sits in a gap that the more familiar ones leave open. Our binomial distribution calculator fixes the number of trials and asks how many successes you get. This one fixes the number of successes and asks how many trials it takes. That inversion is why it is called negative binomial, and it is the right model whenever the stopping rule is "keep going until you have enough".

What This Negative Binomial Distribution Calculator Does

It computes the probability mass function, the cumulative distribution and the upper tail for the parameters you supply, plus the mean, variance and standard deviation. It plots the mass function across a window around your chosen value so the shape of the distribution is visible, with the selected point marked.

It also handles both conventions explicitly rather than silently picking one. That matters more here than for most distributions, because the two differ by exactly r and a reader who assumes the wrong one will be out by that amount every time.

All arithmetic is done in log space using a log-gamma function, so large binomial coefficients do not overflow. A run of several thousand trials computes without losing precision to intermediate factorials.

The Boundary With The Geometric Distribution

Set r to 1 and this distribution becomes the geometric distribution exactly. The geometric case asks how long you wait for the first success; the negative binomial generalises it to the rth. Nothing else changes: the same independence assumption, the same constant p, the same right-skewed shape.

That means the two tools overlap at one point and nowhere else. Our geometric distribution calculator is the one to use when r equals 1, and it is built for that case — it handles both conventions for the single-success problem and covers the memorylessness property, which is specific to r = 1 and does not generalise. Use this page whenever r is 2 or more. If you enter r = 1 here the tool will still produce the right answer, and it says so, but the geometric page is the better-fitting explanation.

Penn State's STAT 414 Lesson 11 on geometric and negative binomial distributions presents them together for exactly this reason, deriving the geometric first and then extending to the rth success.

How to Use It

  1. Set r to the number of successes you are waiting for. It must be a positive whole number in this tool.
  2. Set p to the per-trial success probability. It must be constant across trials for the model to apply.
  3. Pick the convention before entering k, because the same number means different things under the two.
  4. Enter k and read the point probability in the hero and the two tails in the grid.
  5. Check the mean against your k. If k sits far below the mean, the point probability will be small for reasons of position rather than of parameters.

The Formula and How It Is Calculated

Under the trials convention, let X be the trial on which the rth success occurs. For the rth success to land on trial k, exactly r − 1 successes must appear somewhere in the first k − 1 trials, and trial k itself must be a success. That gives the mass function P(X = k) = C(k − 1, r − 1) × pⁿ × (1 − p)^(k − r), defined for k = r, r + 1, r + 2 and upwards. This is the form Penn State's lesson states.

Under the failures convention, let Y count only the failures that occur before the rth success, so Y = X − r and Y starts at zero. The mass function becomes P(Y = y) = C(y + r − 1, r − 1) × pⁿ × (1 − p)ʸ. Wolfram MathWorld's negative binomial distribution page uses this second form, describing r − 1 successes and x failures in x + r − 1 trials followed by a success on the next.

The moments follow directly. Under the trials convention the mean is r divided by p and the variance is r(1 − p) divided by p². Under the failures convention the variance is identical — shifting a distribution does not change its spread — but the mean is r(1 − p) divided by p, which is exactly r less. The tool reports whichever pair matches your selected convention.

Advertisement

Which Convention Your Source Is Using

There is no way to tell from the phrase "negative binomial" alone, and both appear in respectable references, so it is worth knowing how to check quickly.

The fastest test is the support. If your source says the variable starts at r, it is counting trials. If it says the variable starts at zero, it is counting failures. The second-fastest test is the mean: r divided by p means trials, and r(1 − p) divided by p means failures. A third check is the coefficient — C(k − 1, r − 1) indicates trials, while C(k + r − 1, r − 1) indicates failures.

Software is split. Several statistical packages and libraries use the failures convention by default because it keeps the support starting at zero, which is convenient for regression and for the Poisson-gamma mixture form. Many probability textbooks use the trials convention because the derivation reads more naturally. Neither is more correct; converting between them is a shift by r and nothing else, which the tool does when you switch the selector.

Where The Model Actually Fits

The assumptions are strict: independent trials, a success probability that does not change, and a stopping rule fixed in advance at r successes. Where those hold, the model is exact rather than approximate.

Reliability testing fits well — run units until the third failure and the number of units consumed is negative binomial. So does acceptance sampling with a stop-on-r rule, and so does any sequential procedure that ends after a fixed count of events rather than after a fixed number of observations.

The place it breaks is where the trials are not exchangeable. Contacting prospects until you close three deals looks like a textbook example, but the probability of closing is not constant across a list, and it is usually not independent either — a working list gets worked in order of quality. The model will then understate the tail, because the easy successes come first and the later trials are harder than p suggests. That failure mode is the same one that makes our binomial and Poisson distribution calculators misfire on real-world data, and the fix is the same: check whether the units are genuinely alike before assuming a common p.

Overdispersion And The Other Negative Binomial

There is a second, quite different use of this distribution that is worth flagging because the name collides. In count-data regression, "negative binomial" refers to a model for counts that are more variable than the Poisson distribution allows.

The connection is real. If counts follow a Poisson distribution whose rate itself varies across units according to a gamma distribution, the resulting marginal distribution is negative binomial. In that setting r is estimated from data as a dispersion parameter, is not required to be a whole number, and has nothing to do with waiting for a fixed number of successes.

This calculator implements the discrete waiting-time version with integer r, which is the one taught in probability courses and the one nearly every search for the term is looking for. If you have arrived here from a regression output showing a negative binomial dispersion parameter, that quantity is not the r on this page, and fitting it requires estimation software rather than a closed form.

Reading The Shape

The distribution is right-skewed for every parameter combination, and the skew is heavier for small r. With r = 1 the mode is at the first possible value and the mass decays geometrically from there. As r grows the mode moves rightward and the shape becomes gradually more symmetric, which is the central limit theorem arriving: a wait for r successes is a sum of r independent geometric waits.

That sum structure explains the moments without any algebra. Each geometric wait has mean 1 divided by p, so r of them have mean r divided by p. Each has variance (1 − p) divided by p², and independent variances add, giving r(1 − p) divided by p². It also explains why a normal approximation improves as r grows, which our normal approximation calculator covers for the discrete distributions where that approximation is routinely used.

One consequence catches people out. Because the distribution is skewed, the mean is not the most likely outcome and is not the median either. With r = 3 and p = 0.4 the mean wait is 7.5 trials, but the single most likely trial number is lower than that, and roughly half of all runs finish before the mean. Planning to the mean of a skewed waiting time systematically underestimates how often you will run long. The binomial coefficient calculator handles the combinatorial term on its own if you want to check a step by hand.

Planning around a process that runs until it hits a target?

Arb Digital models campaign volume against the spread of outcomes rather than the average, because the average of a skewed wait is not the outcome you should budget for.

Browse All Free Tools Talk To Our Team

Common Mistakes to Avoid

  • Mixing the two conventions — trials and failures differ by exactly r, and using one formula with the other's k is out by that amount every time.
  • Applying it when p varies across trials — a list worked best-first breaks the constant-probability assumption and the model understates the tail.
  • Confusing it with the binomial — the binomial fixes trials and counts successes; this fixes successes and counts trials.
  • Planning to the mean — the distribution is right-skewed, so the mean is above the mode and roughly half of runs finish sooner than it.
  • Assuming the regression parameter is this r — the overdispersion parameter in count-data regression is estimated from data and need not be a whole number.

Related Free Tools From Arb Digital

Handle the r equals 1 case with the geometric distribution calculator, fix the trials instead with the binomial distribution calculator, model rare event counts with the Poisson distribution calculator, sample without replacement using the hypergeometric distribution calculator, or check a combinatorial term with the binomial coefficient calculator. The free online tools hub lists every probability tool we publish.

Frequently Asked Questions

What does the negative binomial distribution model?

The number of independent trials needed to reach a fixed number of successes, where each trial succeeds with the same probability. It fixes the successes and treats the trial count as random.

How is it different from the binomial distribution?

The binomial fixes the number of trials and asks how many successes occur. The negative binomial fixes the number of successes and asks how many trials it takes. The roles of the two quantities are swapped.

Which parameterisation does this calculator use?

Both, selectable. The trials convention counts trials until the rth success and starts at r. The failures convention counts failures before it and starts at zero. They differ by exactly r.

Is the geometric distribution a special case?

Yes. Setting r to 1 gives the geometric distribution exactly, which models the wait for the first success. Our geometric distribution calculator is built specifically for that case.

What are the mean and variance?

Under the trials convention the mean is r divided by p and the variance is r times (1 minus p) divided by p squared. Under the failures convention the variance is the same and the mean is r less.

Can r be a non-integer?

Not in this calculator, which implements the discrete waiting-time model. A non-integer dispersion parameter appears in negative binomial regression, which is a different use of the same name.

Why is the distribution skewed to the right?

Because the wait has a hard lower bound at r trials but no upper bound. A long unlucky run of failures can push the total arbitrarily high, so the right tail stretches while the left cannot.

This page explains a standard probability distribution for educational purposes. Its results hold only where trials are independent and the success probability is genuinely constant, which real processes frequently violate.

Advertisement
Advertisement

Take it further