What this calculator does
The Negative Binomial Mean and Variance Calculator returns the first two moments of a negative binomial distribution. In the standard "failures-before-successes" parameterization, the random variable X counts the number of failures that occur before the r-th success in a sequence of independent Bernoulli trials, where each trial succeeds with probability p. Enter r and p, and the tool reports the mean, the variance, and the standard deviation of X.
How it works
Each trial is an independent success-or-failure experiment with a constant success probability p. You keep sampling until you have accumulated r successes; X is the number of failures observed along the way. Because X can be written as the sum of r independent geometric variables, each counting the failures before a single success, its mean and variance are exactly r times the mean and variance of one geometric term. This yields closed-form expressions that depend only on r and p.
Formula
The mean, variance, and standard deviation of X are:
Here r is the target number of successes and p is the per-trial success probability, with 0 < p <= 1. Note that the variance is always larger than the mean by a factor of 1/p, so the negative binomial is over-dispersed relative to the Poisson.
Worked example
Suppose you need r = 5 successes and each trial succeeds with probability p = 0.5. The mean number of failures before the 5th success is 5(1 - 0.5)/0.5 = 5. The variance is 5(1 - 0.5)/0.5^2 = 2.5/0.25 = 10, so the standard deviation is sqrt(10) which is about 3.16. On average you expect roughly 5 failures, with a typical spread of about 3 failures around that mean.
FAQ
Which negative binomial parameterization does this use? It uses the standard "number of failures before the r-th success" convention, so the mean is r(1-p)/p. If your textbook counts total trials instead of failures, add r to the mean to convert between conventions.
Does r have to be a whole number? For the classic counting interpretation r is a positive integer, but the mean and variance formulas remain valid for any real r > 0, which is the case in the generalized (Polya) negative binomial distribution.
What happens as p approaches 1? When p is close to 1 almost every trial succeeds, so there are almost no failures and both the mean and the variance approach 0. As p gets small, failures accumulate and both moments grow rapidly.
Negative Binomial Mean and Variance Across Different r and p Values
The table uses the \(X\) = number of failures before the \(r\)-th success parameterization, with mean \(\mu = r(1-p)/p\) and variance \(\sigma^2 = r(1-p)/p^2\). The variance-to-mean ratio simplifies to \(1/p\).
| r | p | Mean r(1-p)/p | Variance r(1-p)/p² | Standard deviation | Variance-to-mean ratio 1/p |
|---|---|---|---|---|---|
| 1 | 0.5 | 1 | 2 | 1.4142 | 2 |
| 5 | 0.5 | 5 | 10 | 3.1623 | 2 |
| 5 | 0.2 | 20 | 100 | 10 | 5 |
| 10 | 0.8 | 2.5 | 3.125 | 1.7678 | 1.25 |
| 3 | 0.1 | 27 | 270 | 16.4317 | 10 |
Worked check for r = 5, p = 0.2: \(\mu = 5(0.8)/0.2 = 4/0.2 = 20\), \(\sigma^2 = 5(0.8)/0.2^2 = 4/0.04 = 100\), \(\sigma = \sqrt{100} = 10\), and \(1/p = 5 = 100/20\).
Definitions and Glossary
- r: the target number of successes; the process stops at the r-th success. It is a positive integer in the classic form (the distribution can be extended to positive real values).
- p: the probability of success on each independent trial, with 0 < p ≤ 1.
- X: the number of failures observed before the r-th success, taking values 0, 1, 2, …
- Mean: the expected value of X, \(E[X] = r(1-p)/p\).
- Variance: the expected squared deviation from the mean, \(\operatorname{Var}(X) = r(1-p)/p^2\).
- Standard deviation: the square root of the variance, \(\sqrt{r(1-p)}/p\).
- Overdispersion: variance greater than the mean. The negative binomial is overdispersed whenever 0 < p < 1.
- Geometric distribution: the special case r = 1, counting failures before the first success, with mean \((1-p)/p\) and variance \((1-p)/p^2\).
- Total-trials parameterization: if Y = X + r counts all trials up to and including the r-th success, then the mean is \(r/p\) while the variance stays \(r(1-p)/p^2\), because adding the constant r shifts the mean but not the spread.