Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Negative Binomial Distribution






Negative Binomial Distribution: Trials Until the r-th Success


The negative binomial distribution extends the geometric experiment by continuing the sequence of independent Bernoulli trials until a specified number of successes is reached. Rather than stopping at the first success, the experiment proceeds until the
rr-th success occurs. The random variable measures the total number of trials required to reach this target, capturing variability in how long repeated success takes to accumulate.

Key Terms

Negative Binomial Distribution— trials needed to achieve rr successes
Geometric Distribution— the r=1r=1 special case
Bernoulli Experiment— the single trial repeated until rr successes
Sequence of Bernoulli Trials— the repeated structure of the negative binomial
Expected Value— E[X]=r/pE[X] = r/p
Variance— Var⁡(X)=r(1−p)/p2\operatorname{Var}(X) = r(1-p)/p^2

See All Probability Definitions →


The Probabilistic Experiment Behind negative binomial distribution

The geometric distribution already answers one waiting question: how many flips until the first head.
For a fair coin the first head arrives on flip kk with probability (12)k−1⋅12\left(\frac{1}{2}\right)^{k-1} \cdot \frac{1}{2}: a run of tails, then a head.
Ask instead how many flips until the third head, and the geometric formula has no answer.
Before the third head there are two earlier heads, and they can sit anywhere among the earlier flips. A single run of tails followed by one head no longer describes the sequence, so the waiting time has to be counted afresh.
third head on flip kways to place the first 2 heads in k − 1 flipsprobability
311/8 = 0.125
433/16 ≈ 0.188
566/32 ≈ 0.188
61010/64 ≈ 0.156
71515/128 ≈ 0.117
The definition
The negative binomial distribution with parameters rr and pp is the distribution of the number of independent trials needed to reach rr successes: P(X=k)=(k−1r−1)pr(1−p)k−rP(X = k) = \binom{k-1}{r-1} p^r (1 - p)^{k-r} for k=r,r+1,…k = r, r + 1, \dots
So the flips until the third head form a negative binomial with r=3r = 3, p=12p = \frac{1}{2} — like a game played until someone has won three rounds, not until the first round is won.
It is a waiting time again — now for several successes rather than one.
The negative binomial distribution generalizes the geometric distribution by counting the number of trials required until a fixed number of successes is reached, rather than just the first success. Trials are independent Bernoulli experiments with constant success probability, and the process continues until the target number of successes is achieved.
Here, the random variable counts the total number of trials, including both successes and failures. The number of successes is fixed in advance, while the number of failures — and thus the total length of the experiment — is random.
This distribution is useful when success must occur multiple times before stopping, and the timing of those successes is uncertain.

Example
Flipping a coin until you obtain 33 heads. If X=7X=7, this means the third head appears on the seventh flip. The sequence ends at the moment the third success occurs.
Nothing is lost: with r = 1 the new distribution is the old one.
Setting r=1r = 1 in the formula leaves (k−10)p(1−p)k−1=(1−p)k−1p\binom{k-1}{0} p (1 - p)^{k-1} = (1 - p)^{k-1} p, the geometric distribution exactly.
COROLLARY
When the required number of successes is 11, the negative binomial distribution reduces exactly to the geometric distribution.
The negative binomial fixes the number of successes and leaves the number of trials to chance.
What changes: the formula needs a count of arrangements, and books disagree on what X counts.
The factor (k−1r−1)\binom{k-1}{r-1} is the price of waiting for more than one success — it counts where the earlier successes can fall. And some texts let XX count only the failures before the rr-th success, which shifts the values down by rr; this page counts all trials, as the probability mass function section shows.
The rest of the page covers the notation, the parameters, the PMF and CDF, the mean, variance, mode and median, and further properties.

Negative Binomial Notation

Notation

Negative Binomial Notation

The negative binomial inherits the geometric's two-definitions problem and raises it: two rival counts, a coefficient with a deliberate shift in both slots, and a support that starts at rr instead of zero or one. The marks below are how to tell which negative binomial a source means. All catalogued among the probability symbols.
The declaration tilde and capital/lowercase split come from random variable notation and distribution notation; q=1−pq = 1 - p from binomial notation; the coefficient's spellings from binomial coefficient notation; E[X]E[X] and Var⁡(X)\operatorname{Var}(X) from expected value and variance notation.
X∼NB⁡(r,p)X \sim \operatorname{NB}(r, p)
negative binomial: repeat until the r-th success, with success probability p
NB⁡\operatorname{NB}, NegBin⁡\operatorname{NegBin}, spelled-out NegativeBinomial⁡\operatorname{NegativeBinomial} — and, in older texts, the Pascal distribution for the trials-counting version. The new slot is rr, the target number of successes; setting it to one collapses the family onto the geometric: NB⁡(1,p)=Geom⁡(p)\operatorname{NB}(1, p) = \operatorname{Geom}(p), conventions and all.
CasesBoth of the geometric's rival definitions scale up: XX counts the trials up to the rr-th success, or the failures before it — and software leans failures while texts lean trials, exactly as before; every fingerprint from the geometric's entry applies here with rr in place of one.
Do not confuseThe binomial. The names differ by one word and the letters overlap, but the roles flip: the binomial fixes the trials and counts successes, the negative binomial fixes the successes and counts trials — what is held constant is the entire difference, and the declaration's slots encode it.
P(X=k)=(k−1r−1)prqk−rP(X{=}k) = \dbinom{k-1}{r-1} p^r q^{k-r}
arrange the first k-minus-one trials; the last one is pinned as the r-th success
The coefficient's double shift is the formula's signature: the final trial must be the rr-th success, so only the first k−1k{-}1 trials are free to arrange, and only r−1r{-}1 successes go among them — (k−1r−1)\binom{k-1}{r-1}, not (kr)\binom{k}{r}. The failure abbreviation q compresses the tail as usual.
CasesThe failures-counting convention wears a different coat: (k+r−1k)prqk\binom{k+r-1}{k} p^r q^k — same pinned-last-trial logic, re-indexed so kk counts failures alone; the coefficient's shape (shifted top-and-bottom vs summed top) is itself a fingerprint of which convention is in force.
Do not confuseThe binomial's unshifted (nk)\binom{n}{k}. Restoring the "missing" ones — writing (kr)\binom{k}{r} — counts every arrangement of rr successes in kk trials, including those whose rr-th success came earlier, sequences that never stop at kk; the shift is the mathematics, not a typo.
k=r, r+1, r+2, …k = r,\ r{+}1,\ r{+}2,\ \ldots
the support opens at r: fewer trials cannot hold r successes
The family's fourth support style: a shifted open list — unbounded above like the Poisson's, but starting at rr, since rr successes need at least rr trials. The failures convention starts its list at 00 instead — the support line, once again, is the convention's fingerprint.
CasesAll four family support styles are now on record: the binomial's closed list, the Poisson's open ellipsis, the hypergeometric's computed clamps, and this shifted open list — reading the support clause identifies the family before the formula does.
Do not confuseA sum from zero. Summing the trials-convention pmf from k=0k = 0 adds terms with negative factorial arguments — the support clause is not decoration but the guard that keeps the coefficient meaningful.
DownloadPNG2×PDF
Notation · Cheat sheet
Distribution Notation at a Glance
The marks from the notation cards across the distribution pages: how each is read and what it means. Every group links to the full card on its page.
Distributions
(Ω,F,P)(\Omega, \mathcal{F}, \mathbb{P})
a probability space
Outcomes, events, and the probability measure.
PX(A)\mathbb{P}_X(A)
the distribution of X
Equals P(X∈A)\mathbb{P}(X \in A).
X=dYX \overset{d}{=} Y
equal in distribution
Same law, not necessarily the same values.
Binomial
X∼Bin⁡(n,p)X \sim \operatorname{Bin}(n, p)
binomial, n trials, p
The number of successes in nn independent trials.
q=1−pq = 1 - p
q, the failure probability
An abbreviation, not a new parameter.
Geometric
Geom⁡(p)\operatorname{Geom}(p)
geometric with p
Two conventions: count trials, or count failures.
qk−1pq^{k-1}p vs qkpq^k p
the two pmfs
The exponent shows which convention is in use.
Negative binomialThis page
NB⁡(r,p)\operatorname{NB}(r, p)
negative binomial
Trials until the rr-th success.
k=r,r+1,…k = r, r{+}1, \ldots
the support starts at r
Fewer trials cannot hold rr successes.
Hypergeometric
Hyp⁡(N,K,n)\operatorname{Hyp}(N, K, n)
hypergeometric
Population NN with KK successes; nn draws without replacement.
(Kk)(N−Kn−k)(Nn)\frac{\binom{K}{k}\binom{N-K}{n-k}}{\binom{N}{n}}
the pmf
Successes chosen, failures chosen, over all samples.
Poisson
Pois⁡(λ)\operatorname{Pois}(\lambda)
Poisson with rate lambda
Counts of events in a window.
λ\lambda
lambda
The expected count per window; it depends on the window size.
Discrete uniform
DU⁡(a,b)\operatorname{DU}(a, b)
discrete uniform
Each integer from aa to bb equally likely.
1b−a+1\frac{1}{b - a + 1}
one over the count
The +1+1 counts both endpoints.
Continuous uniform
X∼U(a,b)X \sim U(a, b)
uniform from a to b
The slots are the endpoints, not a centre and a spread.
1b−a\frac{1}{b - a}
one over the width
A flat density; no +1+1 here.
Exponential
Exp⁡(λ)\operatorname{Exp}(\lambda)
exponential with rate lambda
Some books put the scale β=1λ\beta = \frac{1}{\lambda} in the slot.
P(X>x)=e−λxP(X > x) = e^{-\lambda x}
the survival tail
The chance of waiting longer than xx.
Normal
N(μ,σ2)N(\mu, \sigma^2)
normal, mean mu
Second slot: usually the variance; some texts use σ\sigma.
Z∼N(0,1)Z \sim N(0, 1)
capital Z, standard normal
A score z=x−μσz = \frac{x - \mu}{\sigma} counts standard deviations.
φ(z),  Φ(z)\varphi(z), \; \Phi(z)
phi; capital Phi
The standard normal density and its CDF.
Same marks, different job
N(μ,σ2)N(\mu, \sigma^2)Check whether the second slot is the variance or the standard deviation.
Exp⁡(λ)\operatorname{Exp}(\lambda)Rate or scale: the two readings give means 1λ\frac{1}{\lambda} and λ\lambda.
U(a,b)U(a, b) vs DU⁡(a,b)\operatorname{DU}(a, b)Width b−ab - a against a count of b−a+1b - a + 1 values.
Φ\Phi vs φ\varphiCapital is the CDF, lowercase the density.
Distribution Notation at a Glance·/probability/distributionsLearn Math Class

Parameters


rr: number of successes to achieve (a positive integer)

pp: probability of success in each trial, with 0<p≤10<p≤1

This distribution models the number of trials needed to observe rr successes, assuming each trial is independent and has the same probability pp of success.

The outcomes are integers rr, r+1r+1 ,r+2r+2 ,…, since at least rr trials are needed.

rr controls the target (how many successes), and pp controls the chance of achieving each one — together, they define how spread out or concentrated the distribution is.
Negative binomial PMFs with p = 0.4 for r = 1, 3 and 5 successesky510152025p = 0.4 in all threeblue: r = 1, mean 2.5amber: r = 3, mean 7.5navy: r = 5, mean 12.5Larger r: the bars start at k = r, move right and spread out
What r does

Three negative binomial PMFs, all with p = 0.4. Blue, r = 1: the geometric case, tallest at k = 1. Amber, r = 3: the bars start at k = 3 and peak a few trials later. Navy, r = 5: they start at k = 5, sit further right and spread wider. The mean r/p grows from 2.5 to 7.5 to 12.5 trials.

Every PMF here starts at k = r: fewer than r trials cannot hold r successes.

Probability Mass Function (PMF) and Support (Range)


The probability mass function (PMF) of a negative binomial distribution is given by:

Negative Binomial PMF
P(X=k)=(k−1r−1)pr(1−p)k−r,k=r,r+1,r+2,…P(X = k) = \binom{k-1}{r-1} p^r (1-p)^{k-r}, \quad k = r, r+1, r+2, \ldots
Learn more about this formula: Negative Binomial PMF →


where (k−1r−1)=(k−1)!(r−1)!(k−r)!\binom{k-1}{r-1} = \frac{(k-1)!}{(r-1)!(k-r)!} is the binomial coefficient.

Fixed Number of Successes: The negative binomial distribution models the number of trials needed to achieve exactly rr successes in a sequence of independent Bernoulli trials.

Support (Range of the Random Variable):
* The random variable XX can take on values r,r+1,r+2,…r, r+1, r+2, \ldots (integers starting from rr).
* X=kX = k means the rr-th success occurs on the kk-th trial.
* The support is thus a countably infinite set.

Logic Behind the Formula:
* (k−1r−1)\binom{k-1}{r-1}: The number of ways to arrange r−1r-1 successes in the first k−1k-1 trials (the kk-th trial must be the rr-th success)
* prp^r: The probability of getting exactly rr successes
* (1−p)k−r(1-p)^{k-r}: The probability of getting exactly k−rk-r failures
* The total probability sums to 1:

∑k=r∞P(X=k)=∑k=r∞(k−1r−1)pr(1−p)k−r=1\sum_{k=r}^{\infty} P(X = k) = \sum_{k=r}^{\infty} \binom{k-1}{r-1} p^r (1-p)^{k-r} = 1

* This follows from the negative binomial series expansion.

Did you know: Where the negative comes from
With q=1−pq = 1 - p, the probabilities are exactly the terms of pr(1−q)−rp^r (1 - q)^{-r} expanded by Newton's binomial series. The exponent −r-r is the negative in the name, and since (1−q)−r=p−r(1 - q)^{-r} = p^{-r}, the terms add up to pr⋅p−r=1p^r \cdot p^{-r} = 1.

That expansion is the binomial theorem stretched beyond whole-number powers. Newton showed that (1+x)n(1 + x)^n can be expanded for any exponent nn, not only for n=1,2,3,…n = 1, 2, 3, \ldots, at the price of an infinite series in place of a finite sum. For exponents that are not positive whole numbers the expansion never stops, which is just what an unbounded support needs: one term for each possible number of trials.

Negative Binomial Distribution

Trials until r-th success (generalization of geometric)

Explanation

The negative binomial distribution models the number of trials needed to achieve rr successes in repeated independent trials. The probability mass function is P(X=k)=(k−1r−1)pr(1−p)k−rP(X = k) = \binom{k-1}{r-1} p^r (1-p)^{k-r}. The expected value is E[X]=rpE[X] = \frac{r}{p} and the variance is Var(X)=r(1−p)p2\text{Var}(X) = \frac{r(1-p)}{p^2}. This distribution is used for modeling scenarios like the number of calls until rr sales are made, games played until rr wins are achieved, or attempts until rr successes occur.

0.0000.0300.0600.0900.1200.1503579111315171921Value (k)Probability P(X = k)
Negative binomial PMF, r = 3, p = 0.4

The bars start at r, the fewest trials that can hold r successes, rise to a peak and then decay in a long right tail; the geometric distribution is the special case r equal to 1. Each height multiplies a binomial coefficient by p to the r and (1 minus p) to the k minus r. Raise r and watch the whole pattern shift right and widen on the PMF visualizer.

The CDF has no closed form and is summed term by term.
The last trial is always the final success, so only the trials before it are free to arrange.

Cumulative Distribution Function (CDF)


The cumulative distribution function (CDF) of a negative binomial distribution is given by:

Cumulative Distribution Function (CDF)
FX(k)=P(X≤k)=∑i=rk(i−1r−1)pr(1−p)i−rF_X(k) = P(X \leq k) = \sum_{i=r}^{k} \binom{i-1}{r-1} p^r (1-p)^{i-r}

Where:
rr = number of successes desired (fixed, positive integer)
pp = probability of success on each trial
kk = number of trials until the rr-th success (where k≥rk \geq r)
(i−1r−1)\binom{i-1}{r-1} = binomial coefficient

Intuition Behind the Formula


Definition: The CDF gives the probability that the rr-th success occurs on or before trial kk.

Summation of Probabilities:
We sum the PMF values from the minimum possible value (rr trials) up to kk trials:

Cumulative Distribution Function (CDF)
P(X≤k)=P(X=r)+P(X=r+1)+P(X=r+2)+⋯+P(X=k)P(X \leq k) = P(X=r) + P(X=r+1) + P(X=r+2) + \cdots + P(X=k)

Alternative Formulation via Regularized Incomplete Beta Function:
The CDF can also be expressed using the regularized incomplete beta function:

Cumulative Distribution Function (CDF)
FX(k)=Ip(r,k−r+1)F_X(k) = I_p(r, k-r+1)

This relationship connects the negative binomial distribution to the beta distribution and is often used in statistical software for efficient computation.

Complementary Form:
The probability that the rr-th success occurs after trial kk is:

Cumulative Distribution Function (CDF)
P(X>k)=1−FX(k)P(X > k) = 1 - F_X(k)

Negative Binomial Distribution CDF

CDF for waiting time until r-th success

CDF Explanation

The negative binomial CDF is F(k)=P(X≤k)=∑i=rk(i−1r−1)pr(1−p)i−rF(k) = P(X \leq k) = \sum_{i=r}^{k} \binom{i-1}{r-1} p^r (1-p)^{i-r} for k≥rk \geq r. This gives the probability that the rr-th success occurs on or before trial kk. The CDF begins at k=rk = r (minimum trials needed for rr successes) with value F(r)=prF(r) = p^r. As kk increases, the CDF approaches 1.0. The distribution generalizes the geometric distribution (which is the special case r=1r = 1), and its shape depends on both the number of required successes rr and the success probability pp.

Expected Value (Mean)


As explained in the general case for calculating expected value, the expected value of a discrete random variable is computed as a weighted sum where each possible value is multiplied by its probability:

Expected Value (Discrete)
E[X]=∑xx⋅P(X=x)E[X] = \sum_{x} x \cdot P(X = x)
Learn more about this formula: Expected Value (Discrete) →


For the negative binomial distribution, we apply this general formula to the specific probability mass function of this distribution.

Formula


Negative Binomial Mean
E[X]=rpE[X] = \frac{r}{p}
Learn more about this formula: Negative Binomial Mean →


Where:
rr = number of successes desired (fixed, positive integer)
pp = probability of success on each trial

Derivation and Intuition


The negative binomial random variable XX represents the number of trials needed to achieve rr successes. It can be viewed as the sum of rr independent geometric random variables, where each represents the number of trials needed to achieve one additional success.

Since each geometric variable has expected value 1p\frac{1}{p}, and we need rr such successes:

Expected Value (Mean)
E[X]=r⋅1p=rpE[X] = r \cdot \frac{1}{p} = \frac{r}{p}

This result follows directly from the linearity of expectation applied to the sum of rr geometric random variables.

The result E[X]=rpE[X] = \frac{r}{p} extends the geometric distribution's intuition: if you need one success and expect 1p\frac{1}{p} trials, then needing rr successes should require rr times as many trials on average.

Example


Consider rolling a die until you get three 6's, where r=3r = 3 and p=16p = \frac{1}{6}:

Expected Value (Mean)
E[X]=31/6=18E[X] = \frac{3}{1/6} = 18

Pitfall: Mixing up trials and failures
Reading E[X]=18E[X] = 18 as the number of rolls that miss counts the three 6's among the failures. The misses before the third 6 average 18−3=1518 - 3 = 15, the mean r(1−p)p\frac{r(1-p)}{p} of the failure count.

On average, you expect to roll the die 18 times before accumulating three 6's. This is exactly three times the expected wait for a single 6.

To compute the expected value of a negative binomial distribution for your own parameters, step by step, use the negative binomial expected value calculator.
0.0000.0150.0300.0450.0600.075591317212529333741454950Value (k)Probability P(X = k)E[X]=16.67
Negative binomial PMF with the mean marked

The marked mean sits to the right of the peak because of the long right tail: the expected number of trials is r over p, so each additional required success adds 1 over p trials on average. Linearity of expectation gives this without any summation. Change r and p and watch the mean marker move on the distribution explorer.

The variance is derived by the same additive argument.
Each required success adds its own geometric wait, so the mean grows by 1/p trials per success.

Variance and Standard Deviation


The variance of a discrete random variable measures how spread out the values are around the expected value. It is computed as:

Variance and Standard Deviation
Var(X)=E[(X−μ)2]=∑x(x−μ)2P(X=x)\mathrm{Var}(X) = \mathbb{E}[(X - \mu)^2] = \sum_{x} (x - \mu)^2 P(X = x)

Or using the shortcut formula:

Variance and Standard Deviation
Var(X)=E[X2]−μ2\mathrm{Var}(X) = \mathbb{E}[X^2] - \mu^2

For the negative binomial distribution, we apply this formula to derive the variance.

Formula


Negative Binomial Variance
Var(X)=r(1−p)p2\mathrm{Var}(X) = \frac{r(1-p)}{p^2}
Learn more about this formula: Negative Binomial Variance →


Where:
rr = number of successes desired (fixed, positive integer)
pp = probability of success on each trial
(1−p)=q(1-p) = q = probability of failure on each trial

Derivation and Intuition


THEOREM
The negative binomial random variable can be viewed as the sum of rr independent geometric random variables, each representing the trials needed for one additional success.

Since each geometric variable has variance 1−pp2\frac{1-p}{p^2}, and variances add for independent variables:

Variance and Standard Deviation
Var(X)=r⋅1−pp2=r(1−p)p2\mathrm{Var}(X) = r \cdot \frac{1-p}{p^2} = \frac{r(1-p)}{p^2}

The result Var(X)=r(1−p)p2\mathrm{Var}(X) = \frac{r(1-p)}{p^2} extends the geometric distribution's variance by a factor of rr. As with the geometric case, variance increases rapidly as pp decreases (rare successes create high variability) and grows linearly with the number of required successes rr.

Standard Deviation


Variance and Standard Deviation
σ=r(1−p)p2=r(1−p)p\sigma = \sqrt{\frac{r(1-p)}{p^2}} = \frac{\sqrt{r(1-p)}}{p}

Example


Consider rolling a die until you get three 6's, where r=3r = 3 and p=16p = \frac{1}{6}:

Variance and Standard Deviation
Var(X)=3×56(16)2=156136=52×36=90\mathrm{Var}(X) = \frac{3 \times \frac{5}{6}}{(\frac{1}{6})^2} = \frac{\frac{15}{6}}{\frac{1}{36}} = \frac{5}{2} \times 36 = 90

Variance and Standard Deviation
σ=90≈9.487\sigma = \sqrt{90} \approx 9.487

Pitfall: Multiplying the standard deviation by r
Taking 33 times the geometric standard deviation, 330≈16.43\sqrt{30} \approx 16.4 rolls, overstates the spread. Variances add, standard deviations do not: σ=3×30=90≈9.5\sigma = \sqrt{3 \times 30} = \sqrt{90} \approx 9.5.

The variance of 90 and standard deviation of about 9.5 indicate high variability around the expected 18 rolls. The actual number of rolls needed could vary substantially from this average.
Nine trials F F S F S F F F S: the wait for three successes split into three geometric waits of 3, 2 and 4 trialstrial 1234567891011wait 1: 3wait 2: 2wait 3: 4filled: success, hollow: failureX = 3 + 2 + 4 = 9 trials for r = 3each wait is geometric: mean 1/p, variance (1 − p)/p²r successes = r independent geometric waits, end to end
Three successes as three waits

One run of trials until the third success: F F S F S F F F S. Cut it after each success and it splits into three separate waits, of 3, 2 and 4 trials. Each wait is a geometric count that starts fresh, independent of the others, so X = 9 is their sum. Adding r means of 1/p gives r/p; adding r variances of (1 − p)/p² gives r(1 − p)/p².

Variances add only because the waits are independent: each one restarts after a success.

Mode and Median

Mode


The mode is the value of kk (the trial on which the rr-th success occurs) with the highest probability—the peak of the PMF.

For the negative binomial distribution, the mode depends on the parameters rr and pp:

If r>1r > 1:
The mode is r+⌊(r−1)(1−p)p⌋r + \lfloor \frac{(r-1)(1-p)}{p} \rfloor. When (r−1)(1−p)p\frac{(r-1)(1-p)}{p} is a whole number, the value one below is a mode too: two values tie.

If r=1r = 1:
The mode is 11 (this reduces to the geometric distribution: success on the first trial is most likely)
The mode formula, then the two cases where it gives a different answer, each with its reason.
DownloadPNG2×PDF
If r>1r > 1
Mode =r+⌊(r−1)(1−p)p⌋= r + \lfloor \frac{(r-1)(1-p)}{p} \rfloor
(r−1)(1−p)p\frac{(r-1)(1-p)}{p} is wholetwo modes
The value one below is a mode too
Two values tie for the highest probability.
r=1r = 1geometric
Mode =1= 1
r=1r = 1, p=0.4p = 0.4: mode =1= 1
This reduces to the geometric distribution: success on the first trial is most likely.
Where the mode formula changesLearn Math Class
Both rows change the answer, not the method: a tie adds a second mode, and r=1r = 1 turns the distribution into the geometric one.
Intuition: The term (r−1)(1−p)p\frac{(r-1)(1-p)}{p} counts the most likely number of failures; adding the rr successes turns it into a number of trials. The mode sits a little below the expected value rp\frac{r}{p}. As pp decreases (success becomes rarer), the mode shifts rightward.

Example
For r=5r = 5 and p=0.3p = 0.3:
Mode = 5+⌊(5−1)(1−0.3)0.3⌋=5+⌊4×0.70.3⌋=5+⌊9.33⌋=145 + \lfloor \frac{(5-1)(1-0.3)}{0.3} \rfloor = 5 + \lfloor \frac{4 \times 0.7}{0.3} \rfloor = 5 + \lfloor 9.33 \rfloor = 14
The 5th success arriving on exactly the 14th trial is more likely than on any other trial.

Example
For r=1r = 1 and p=0.4p = 0.4:
Mode = 1 (geometric case: most likely to succeed on the first trial)

Median


The median is the value mm such that P(X≤m)≥0.5P(X \leq m) \geq 0.5 and P(X≥m)≥0.5P(X \geq m) \geq 0.5.

For the negative binomial distribution, there is no simple closed-form expression for the median, but it can be found numerically as the smallest mm with:

Mode and Median
∑k=rm(k−1r−1)pr(1−p)k−r≥0.5\sum_{k=r}^{m} \binom{k-1}{r-1} p^r (1-p)^{k-r} \geq 0.5

Properties of the median:
• The median lies between the mode and the mean rp\frac{r}{p} in the examples below
• For r=1r = 1, the median follows the geometric distribution formula
• The distribution is right-skewed, so median < mean typically

Example
For r=3r = 3 and p=0.5p = 0.5:
Mean = 30.5=6\frac{3}{0.5} = 6
P(X≤4)≈0.31P(X \leq 4) \approx 0.31 and P(X≤5)=0.5P(X \leq 5) = 0.5 exactly, so both conditions hold for every mm from 5 to 6: 5 is the smallest median, and 6 qualifies as well

Example
For r=5r = 5 and p=0.3p = 0.3:
Mean = 50.3≈16.67\frac{5}{0.3} \approx 16.67
The median is 16: P(X≤15)≈0.49P(X \leq 15) \approx 0.49, just short of one half

Unlike continuous distributions where finding the median requires integration, for discrete distributions, the median is found by summing probabilities until reaching 0.5.

Applications and Examples


### Practical Example

Suppose you're flipping a coin until you get r=3r = 3 heads, where the probability of heads is p=0.5p = 0.5. The probability that you need exactly k=6k = 6 flips to get your third head is:

P(X=6)=(6−13−1)(0.5)3(0.5)6−3=(52)(0.5)3(0.5)3=10⋅0.125⋅0.125=0.15625P(X = 6) = \binom{6-1}{3-1} (0.5)^3 (0.5)^{6-3} = \binom{5}{2} (0.5)^3 (0.5)^3 = 10 \cdot 0.125 \cdot 0.125 = 0.15625

Pitfall: Counting the successes anywhere
Using the binomial (63)(0.5)6=0.3125\binom{6}{3}(0.5)^6 = 0.3125 counts every way to get 3 heads in 6 flips, including those where the third head came earlier. With the sixth flip fixed as the third head, P(X=6)=(52)(0.5)6=0.15625P(X = 6) = \binom{5}{2}(0.5)^6 = 0.15625.

This means there's a 15.625% chance that you'll need exactly 6 flips to get your third head.

The question fixes when the experiment stops, not only how many heads appear. The sixth flip has to be the third head, so only the first five flips are free, and the other two heads can sit anywhere among them.

Note: The geometric distribution is a special case of the negative binomial distribution where r=1r = 1.

Did you know: Banach's matchboxes
When the first box turns up empty, the other still holds about 77 matches on average, and it is empty too only about 8% of the time. A box is found empty on its 5151st pick, a negative binomial wait with r=51r = 51 and p=12p = \frac{1}{2}, and a fair coin rarely keeps the two counts level that long.

The same stopping rule drives a classic puzzle told about the mathematician Stefan Banach. He carries two matchboxes, one in each pocket, each starting with 5050 matches, and every time he needs a match he picks a pocket at random. Eventually he reaches for a match, opens a box and finds it empty, and the question is how many matches the other box holds at that moment.

Interactive Calculator


This interactive calculator computes probabilities for the negative binomial distribution, which models the number of failures before achieving a target number of successes. Enter your target successes (rr), success probability (pp), and choose whether you want the full distribution or specific probabilities to see how many failures you might encounter. Perfect for modeling customer acquisition, manufacturing quality targets, or any scenario where you need multiple successes and want to know about the failures along the way.

1. Select probability type: 'All values' for full distribution, or choose a specific query
2. Enter r (number of successes) - how many successes you want to achieve
3. Enter p (success probability) - probability of success on each trial (0 < p ≤ 1)
4. For specific queries, enter k (number of failures) - failures before achieving r successes
5. Click Calculate to see probabilities and distribution

Negative Binomial Distribution Calculator

Calculate probabilities and distribution properties

Target number of successes

Probability of success on each trial

,

Related Distributions


The negative binomial distribution extends the geometric wait to several successes. Its relatives are the single wait it is built from, the binomial count of the same trials, a second form that counts failures only, and the Poisson and gamma distributions it approaches.

Geometric: one success at a time


The geometric distribution is the case r=1r = 1. In the other direction, the wait for rr successes is a sum of rr independent geometric waits, one for each success, which is where the mean rp\frac{r}{p} and the variance r(1−p)p2\frac{r(1-p)}{p^2} come from.

Binomial: the same trials read the other way


The binomial distribution fixes the number of trials and counts successes; the negative binomial fixes the successes and counts trials. The rr-th success arrives by trial nn exactly when the first nn trials hold at least rr successes, so for Y∼Bin⁡(n,p)Y \sim \operatorname{Bin}(n, p):

Related Distributions
P(X≤n)=P(Y≥r)P(X \leq n) = P(Y \geq r)

For the third six on a die, the chance that it arrives within 1818 rolls is the chance of at least three sixes in 1818 rolls, about 0.5970.597.

The failure-count form


Many texts and most software count only the failures before the rr-th success, Y=X−rY = X - r, which starts at 00 instead of rr:

Related Distributions
P(Y=j)=(j+r−1j)pr(1−p)j,j=0,1,2,…P(Y = j) = \binom{j + r - 1}{j} p^r (1-p)^j, \quad j = 0, 1, 2, \ldots

The mean drops by rr to r(1−p)p\frac{r(1-p)}{p} and the variance stays r(1−p)p2\frac{r(1-p)}{p^2}. Before using a formula or a software function, check which of the two forms it means.

Poisson: counts with extra spread


Write μ=r(1−p)p\mu = \frac{r(1-p)}{p} for the mean of the failure count. Its variance is then

Related Distributions
Var(Y)=μ+μ2r\mathrm{Var}(Y) = \mu + \frac{\mu^2}{r}

which is always larger than the mean. Let rr grow while μ\mu stays fixed: the extra term fades and the distribution approaches the Poisson with mean μ\mu. For this reason the negative binomial is fitted to counts that vary more than a Poisson allows.

Gamma: the same wait in continuous time


The sum of rr independent exponential waits is the time until the rr-th event at a constant rate, and it follows the gamma distribution. The negative binomial is the same sum made of geometric waits. As the trials come faster and each one succeeds less often, the geometric wait turns into the exponential one, and the negative binomial wait turns into the gamma one.

Of these, the geometric and binomial links are the ones used in calculation: the first gives the mean and variance, the second turns a question about the wait into a question about a count.

Negative Binomial at a Glance

This summary gathers the negative binomial distribution on one card of nine rows. Each row names one part of the distribution with a line on what it gives and a link to the section that explains it, then states the formula or fact and adds a note or a worked number.

The first rows fix the setup: the number of successes to wait for, the chance of success on each trial, and the trial counts that can occur. Then come the probability that the last success lands on a given trial, the running total, the mean, the variance with the standard deviation, and the mode and median. The last rows give the geometric special case and the example of rolling a die until three sixes appear.
DownloadPNG2×PDF
AspectFormula or statementNote or example
ParametersThe two numbers that fix the distribution, as the parameters section explains.rr, the target number of successes (a positive integer); pp, the success probability, 0<p≤10 < p \leq 1trials are independent with constant success probability pp
SupportThe trial numbers on which the rr-th success can land, set out with the PMF and its support.k∈{r,r+1,r+2,…}k \in \{r, r + 1, r + 2, \ldots\}at least rr trials are needed to collect rr successes
PMFThe probability that the rr-th success comes on trial kk, from the PMF section.P(X=k)=(k−1r−1)pr(1−p)k−r,k=r,r+1,r+2,…\displaystyle P(X = k) = \binom{k-1}{r-1} p^r (1-p)^{k-r}, \quad k = r, r+1, r+2, \ldotsthe kk-th trial must be the rr-th success; arrange r−1r - 1 successes among the first k−1k - 1 trials
CDFThe probability of reaching rr successes within kk trials, from the CDF section.FX(k)=P(X≤k)=∑i=rk(i−1r−1)pr(1−p)i−r=Ip(r,k−r+1)\displaystyle F_X(k) = P(X \leq k) = \sum_{i=r}^{k} \binom{i-1}{r-1} p^r (1-p)^{i-r} = I_p(r, k-r+1)no closed form; expressible through the regularized incomplete beta function
Expected valueThe average number of trials needed for rr successes, derived in the expected value section.E[X]=rp\displaystyle E[X] = \frac{r}{p}rr times the geometric wait, by linearity over rr independent geometric waits
VarianceHow widely the number of trials spreads, worked out in variance and standard deviation.Var(X)=r(1−p)p2\displaystyle \mathrm{Var}(X) = \frac{r(1-p)}{p^2}; σ=r(1−p)p\displaystyle \sigma = \frac{\sqrt{r(1-p)}}{p}grows linearly with rr; explodes as p→0p \to 0
Mode and medianThe most likely trial count and the middle of the distribution, found in mode and median.Mode=r+⌊(r−1)(1−p)p⌋\displaystyle \text{Mode} = r + \left\lfloor \frac{(r-1)(1-p)}{p} \right\rfloor trials; the median lies between the mode and the mean and is computed numericallyright-skewed; the median is typically slightly below the mean
Special caseWaiting for a single success is the geometric wait, as the key terms note.NegBin⁡(1,p)=Geom⁡(p)\operatorname{NegBin}(1, p) = \operatorname{Geom}(p)setting r=1r = 1 collapses to the geometric distribution
Canonical exampleThe die-rolling wait the page works through; variance and standard deviation finishes its numbers.rolling a die until three 6s: r=3r = 3, p=1/6p = 1/6E[X]=18E[X] = 18 rolls, Var(X)=90\mathrm{Var}(X) = 90, σ≈9.49\sigma \approx 9.49
Negative binomial distribution at a glance·All probability formulasLearn Math Class
Reading the distribution as several geometric waits placed end to end explains most of the card: the mean and the variance are those of a single wait multiplied by the number of successes, and with a single success the whole card turns into the geometric one.

Common Pitfalls

Three mistakes come up again and again in negative binomial problems. Each one is marked where it happens in the sections above; here each is worked through in full, with the wrong and the right working side by side.
DownloadPNG2×PDF
1Mixing up trials and failures
The mean rp\frac{r}{p} counts all trials, the rr successes included. It is read as the expected number of failures, or it is compared with a result that counts failures only.
Wrong turn
Error here
For a die rolled until three 6's appear, E[X]=31/6=18E[X] = \frac{3}{1/6} = 18 is read as the number of rolls that are not a 6.
Right path
XX counts all the rolls, and three of them are the 6's. The number of failures is Y=X−rY = X - r, so
E[Y]=rp−r=r(1−p)p=3⋅5616=15E[Y] = \frac{r}{p} - r = \frac{r(1-p)}{p} = \frac{3 \cdot \frac{5}{6}}{\frac{1}{6}} = 15
Why it happensThe negative binomial has two conventions, one counting trials and one counting the failures before the rr-th success, and sources and software do not agree on which to use. The formulas in the sections above count trials, while the calculator on this page counts failures.
How to checkLook at where the support starts. Under the trials convention X≥rX \geq r, so here the PMF starts at k=3k = 3; under the failures convention it starts at 00. The two means always differ by exactly rr: 18−15=318 - 15 = 3.
2Multiplying the standard deviation by r
The negative binomial is the sum of rr independent geometric waits, and its standard deviation is taken as rr times the geometric one.
Wrong turn
Error here
For three 6's on a die, the geometric standard deviation is 30≈5.477\sqrt{30} \approx 5.477, so
σ=3×30≈16.43\sigma = 3 \times \sqrt{30} \approx 16.43
Right path
The variances of independent variables add.
Var(X)=30+30+30=90,\mathrm{Var}(X) = 30 + 30 + 30 = 90,

σ=90≈9.487\sigma = \sqrt{90} \approx 9.487
Why it happensThe mean does scale by rr, from 1p\frac{1}{p} to rp\frac{r}{p}, so it seems natural for the spread to scale the same way. The standard deviation is the square root of a sum of variances, so it grows only like r\sqrt{r}.
How to checkSquare the result and compare it with the variance formula. (330)2=270(3\sqrt{30})^2 = 270, three times the 9090 that r(1−p)p2\frac{r(1-p)}{p^2} gives.
3Counting the successes anywhere
The probability that the rr-th success comes on trial kk is computed with the binomial formula for rr successes in kk trials, (kr)pr(1−p)k−r\binom{k}{r} p^r (1-p)^{k-r}.
Wrong turn
Error here
For the third head on flip six, with p=0.5p = 0.5,
P(X=6)=(63)(0.5)3(0.5)3P(X = 6) = \binom{6}{3} (0.5)^3 (0.5)^3

=20⋅0.015625=0.3125= 20 \cdot 0.015625 = 0.3125
This counts every sequence with three heads in six flips, including HHHTTT, where the third head came on flip three and the experiment would already have stopped.
Right path
The sixth flip must be the third head, so the other two heads go among the first five flips.
P(X=6)=(52)(0.5)3(0.5)3P(X = 6) = \binom{5}{2} (0.5)^3 (0.5)^3

=10⋅0.015625=0.15625= 10 \cdot 0.015625 = 0.15625
Why it happensBoth formulas contain the same powers pr(1−p)k−rp^r (1-p)^{k-r}, and the coefficient (kr)\binom{k}{r} is the familiar one from the binomial, so the stopping rule gets lost.
How to checkThe PMF values must add up to 11. With (kr)\binom{k}{r} in place of (k−1r−1)\binom{k-1}{r-1}, the values for p=0.5p = 0.5 and r=3r = 3 add up to 22.
Common pitfalls with the negative binomial distribution·/probability/distributions/discrete/negative-binomialLearn Math Class
Each slip miscounts the trials. The mean rp\frac{r}{p} counts all trials, the successes included; the variance of a sum of rr independent geometric waits is rr times the geometric variance, so the standard deviation grows by r\sqrt{r}; and the rr-th success must come on trial kk, which gives (k−1r−1)\binom{k - 1}{r - 1}. Checking where the support starts, squaring the standard deviation, or adding up the PMF values catches each slip.

Skills You Should Learn

Each skill opens its step-by-step method page. Skills marked "On this page" are taught above.
Taught on this page
More distribution methods

Negative Binomial Distribution FAQ

What is the difference between the binomial and negative binomial?

+
What is held fixed. The binomial fixes the number of trials and counts successes; the negative binomial fixes the number of successes and counts trials. Everything else follows from that swap — the binomial's support is bounded by n, while the negative binomial's runs upward without limit, since any number of trials might be needed.Read more →

How is the negative binomial related to the geometric?

+
The geometric is the case r = 1: NB(1, p) = Geom(p), conventions and all. Going the other way, a negative binomial variable is the sum of r independent geometrics — wait for the first success, then start over and wait for the second, r times. That is why the mean is r/p, exactly r times the geometric's 1/p.Read more →

Why is the coefficient C(k−1, r−1) and not C(k, r)?

+
Because the last trial is pinned. The k-th trial must be the r-th success, or the sequence would have stopped earlier — so only the first k−1 trials are free to arrange, and only r−1 successes go among them. Writing C(k, r) also counts sequences whose r-th success came earlier, such as HHHTTT for the third head on flip six, which would have stopped before trial k. The shift is the mathematics, not a typo.Read more →

Why does the negative binomial support start at r?

+
Because r successes need at least r trials — fewer is impossible, so the list opens at k = r and runs upward without bound. Summing the pmf from k = 0 instead feeds negative arguments into the binomial coefficient. Under the failures convention the list starts at 0, which is itself a fingerprint of which convention is in force.Read more →

Why is it called the negative binomial distribution?

+
Because its probabilities are the terms of a binomial expansion with a negative exponent. With q=1−pq = 1 - p, Newton's binomial series expands (1−q)−r(1 - q)^{-r} into an infinite sum, and multiplying each term by prp^r gives exactly the pmf values, one for each possible number of trials. The exponent −r-r is the negative in the name, and since (1−q)−r=p−r(1 - q)^{-r} = p^{-r}, the terms add up to pr⋅p−r=1p^r \cdot p^{-r} = 1.Read more →

What is Banach's matchbox problem?

+
A puzzle about two boxes of 5050 matches, one in each pocket, with a pocket picked at random for every match. When a box is first found empty, the other still holds about 77 matches on average, and it is empty too only about 8% of the time. A box is found empty on its 5151st pick, a negative binomial wait with r=51r = 51 and p=12p = \frac{1}{2}, and a fair coin seldom splits the picks that evenly for so long.Read more →