Discrete distribution · also called Pascal
Negative binomial distribution
The number of failures before the -th success in independent trials: missed sales calls before the third sale. Allowing to be any positive real number turns it into the standard model for counts that vary more than a Poisson would allow (its variance always exceeds its mean), such as the number of reads of a gene or of claims per policyholder.
Negative binomial probability calculator
P(X ≤ 4) = 0.580096
At the parameters set by the sliders. The shaded region on the plot is the probability; the dots on the CDF mark F at its ends. For a discrete distribution, < and ≤ differ.
PMF
CDF
mean 4.5 · variance 11.25 · sd 3.354 · mode 2
Formulas
| Parameters |
|
|---|---|
| Support | |
| PMF | |
| CDF | |
| Mean | |
| Variance | |
| Mode | |
| MGF |
Conventions differ: some books count trials rather than failures, or swap the roles of and . This page, SciPy's nbinom and NumPy all count failures with success probability .
Worked example
A salesperson closes 20% of calls. What is the probability she makes exactly 5 unsuccessful calls before her third sale?
With and : answer checked by code
How it relates to others
- Sum← Geometric: If are independent Geometric() trial counts, (the failures) is Negative binomial(). checked by code
- Special case→ Geometric: Negative binomial() counts failures before the first success, so adding 1 gives Geometric(). checked by code
- Limit→ Poisson: If with the mean fixed, Negative binomial() tends to Poisson(). checked by code
- Mixture← Gamma: A Poisson count whose rate is itself Gamma() is Negative binomial(): the reason the negative binomial models over-dispersed counts. checked by code
- Sum← Logarithmic: The sum of a Poisson() number of independent Logarithmic() counts is Negative binomial() with and : the negative binomial as a compound Poisson (clusters of events arriving at random). checked by code
All the relationships, as a diagram →
In Python
from scipy import stats
import numpy as np
X = stats.nbinom(n=3, p=0.4)
X.pmf(2) # P(X = 2) = 0.1382
X.cdf(2) # P(X ≤ 2) = 0.3174
X.mean(), X.var() # 4.5, 11.25
X.ppf(0.95) # 95th percentile
X.rvs(size=10, random_state=0)
rng = np.random.default_rng(0)
rng.negative_binomial(n=3, p=0.4, size=10)SciPy and NumPy call r "n".
Choosing between this and its neighbours? Which distribution for count data? · Which distribution for waiting times and lifetimes? · Which prior distribution should I use?