Updated Discrete Probability Tool

Negative Binomial Calculator

Work with both definitions of the negative binomial distribution: failures before the r-th success and the trial of the r-th success. Compute PMF, CDF, tail probabilities, probability tables, mean, variance, MGF and PGF.

Failures Before r-th Success Trial Count of r-th Success CDF and Tail Probabilities Distribution Formulas and Moments

Interactive Negative Binomial Distribution Calculator

Use the tabs to switch between the failures parameterization, the trial-count parameterization, probability tables and a summary of distribution properties. This helps you see how the negative binomial distribution behaves under both common definitions.

Here X counts failures before the r-th success. X can take values k = 0, 1, 2, … and is often written X ∼ NB(r, p) under this parameterization.

Here T counts the trial index of the r-th success. T can take values t = r, r + 1, r + 2, … and is related to X by T = X + r.

This table uses the failures parameterization X ∼ NB(r, p). It lists probabilities and cumulative probabilities for k from 0 up to kmax.

This tab summarizes the main formulas for the negative binomial distribution and evaluates them at your chosen r and p.

Negative Binomial Calculator – Two Definitions, One Flexible Distribution

The negative binomial distribution is a flexible discrete distribution for modeling repeated Bernoulli trials. Instead of fixing the number of trials and counting successes as in the binomial distribution, you fix the number of required successes r and let the random variable track either the number of failures before the r-th success or the trial on which the r-th success occurs. This calculator on MyTimeCalculator supports both parameterizations and brings the main formulas together in one place.

Throughout the article, p denotes the probability of success on each trial and q = 1 − p denotes the probability of failure. All trials are assumed to be independent with the same p from trial to trial.

Definition 1: Failures Before the r-th Success

In the failures parameterization the random variable X counts how many failures occur before the r-th success. The possible values are k = 0, 1, 2, … and we write X ∼ NB(r, p). The probability mass function is

PMF (failures parameterization)

P(X = k) = C(k + r − 1, k) pr qk, for k = 0, 1, 2, …

where C(k + r − 1, k) is the binomial coefficient “k + r − 1 choose k”.

CDF and tail probabilities

The cumulative distribution function and right-tail probabilities are given by finite sums of the PMF:

  • P(X ≤ k) = Σj = 0k C(j + r − 1, j) pr qj
  • P(X ≥ k) = Σj = k C(j + r − 1, j) pr qj = 1 − P(X ≤ k − 1)

Mean and variance for failures

For this parameterization the mean and variance are

  • E[X] = r q / p
  • Var(X) = r q / p²

As p increases the expected number of failures before the r-th success decreases. As p decreases and q increases, the distribution becomes more spread out and the variance grows.

Definition 2: Trial of the r-th Success

In the trial-count parameterization the random variable T counts the total trial index on which the r-th success occurs. The possible values are t = r, r + 1, r + 2, … and the PMF is

PMF (trial-count parameterization)

P(T = t) = C(t − 1, r − 1) pr qt − r, for t = r, r + 1, …

This formula reflects that the r-th success must happen on trial t, with r − 1 successes scattered among the first t − 1 trials and the remaining t − r trials being failures.

Relationship between X and T

The two parameterizations are linked by a simple shift:

  • T = X + r
  • X = T − r

Substituting k = t − r into the failures PMF recovers the trial-count PMF. Many properties, such as the variance, are shared between the two views because shifting a distribution by a constant does not change its variance.

Mean and variance for T

Using the relationship T = X + r and the formulas for X, the mean and variance of T become

  • E[T] = r / p
  • Var(T) = r q / p²

The variance matches that of X while the mean shifts upward by r because T includes the r successful trials themselves.

Connection to the Geometric Distribution

The geometric distribution is the special case r = 1. In the failures parameterization, when r = 1 the PMF reduces to

P(X = k) = qk p, for k = 0, 1, 2, …

which is exactly the distribution of the number of failures before the first success. The mean and variance collapse to the geometric formulas E[X] = q / p and Var(X) = q / p². This shows that the negative binomial distribution is a natural extension of the geometric distribution to the case of r required successes.

Connection to the Binomial Distribution

The binomial distribution chooses a fixed number of trials n and counts the number of successes. The negative binomial chooses a fixed number of required successes r and effectively lets the number of trials be random instead. The combinatorial term C(k + r − 1, k) mirrors the C(n, k) term in the binomial PMF, but the roles of the parameters are swapped.

Moment Generating Function (MGF) and Probability Generating Function (PGF)

For the failures parameterization X ∼ NB(r, p) the moment generating function, when it exists, is

MGF of X

MX(t) = [p / (1 − q et)]r, for values of t such that |q et| < 1.

The probability generating function is

PGF of X

GX(z) = [p / (1 − q z)]r, for |z| < 1 / q.

Derivatives of the PGF at z = 1 and derivatives of the MGF at t = 0 recover the mean and variance formulas already summarized above. These functions are useful in more advanced probability theory, branching processes and count data modeling.

Using the Negative Binomial Calculator

The calculator is structured to match these theoretical ideas:

  • Failures tab: You enter r, p and a particular failure count k. The calculator evaluates P(X = k) = C(k + r − 1, k) pr qk, the CDF P(X ≤ k) and the tail probability P(X ≥ k), along with the mean r q / p and variance r q / p².
  • Trials tab: You enter r, p and a trial t ≥ r. The calculator evaluates P(T = t) = C(t − 1, r − 1) pr qt − r, the CDF P(T ≤ t) and the tail probability P(T ≥ t), along with the mean r / p and variance r q / p².
  • Table tab: You set r, p and a maximum failure count kmax. The tool builds a probability table for k from 0 to kmax with PMF, CDF and tail probabilities side by side.
  • Properties tab: You enter r and p and the calculator evaluates E[X], Var(X), E[T], Var(T) and lists the MGF and PGF formulas for reference.

All calculations are based directly on the standard formulas for the negative binomial distribution using the failures before r-th success parameterization as the primary reference and then mapping to the trial-count view when needed.

Practical Tips for Modeling with the Negative Binomial

  • Use the failures parameterization when you naturally think in terms of “how many misses before hit number r”.
  • Use the trial-count parameterization when you track the exact position of the r-th success in a sequence.
  • Check that r is a positive integer and that p lies strictly between 0 and 1, since boundary values collapse the distribution.
  • Remember that heavy tails can appear for small p, because most of the mass shifts to larger counts of failures or trials.
  • In count regression or overdispersed Poisson modeling, interpret r as a shape parameter that controls extra-Poisson variability.

This Negative Binomial Calculator is intended for learning, coursework, planning and quick probability checks. For complex applied work and model fitting, use it alongside full statistical software or professional guidance.

Negative Binomial FAQs

Frequently Asked Questions About the Negative Binomial Distribution

Short answers to help you interpret failures, trials, parameters and formulas for the negative binomial distribution.

The Pascal distribution is another name for the negative binomial distribution when the shape parameter r is a positive integer. In that setting it counts failures before the r-th success or the trial of the r-th success with the same formulas used here.

The binomial coefficient counts how many distinct sequences of successes and failures produce the same total number of failures before the r-th success or the same trial of the r-th success. Multiplying this count by p and q powers gives the final probability.

When p is small, successes are rare and it usually takes many failures or trials to accumulate r successes. The mean and variance both increase, and the distribution spreads out with a heavier right tail, reflecting the longer waiting time.

In regression modeling the negative binomial often arises as a Poisson distribution with a gamma distributed rate. This mixture representation naturally produces variance larger than the mean and is used when Poisson models underestimate variability in count data.

No. This calculator focuses on the distribution formulas, probabilities and moments for given parameter values. It does not perform parameter estimation, model selection or diagnostics. Use it as a learning and checking tool alongside more complete statistical workflows.