Inputs
Steps
Example Data Table
| # | Mode | r | p | x | n | PMF | log PMF |
|---|
Rows reflect the current inputs at the moment of adding. Use the example loader to generate a quick series.
Formula used
We adopt the "failures before the r-th success" definition. For success probability \(p\), target successes \(r>0\), and failures \(x=0,1,\dots\):
\[ \Pr(X=x) = \binom{x+r-1}{x} (1-p)^{x} p^{\,r} = \frac{\Gamma(x+r)}{\Gamma(r)\,\Gamma(x+1)} (1-p)^x p^r. \]
For the "total trials \(n\)" definition, set \(x=n-r\) (so \(n=r,r+1,\dots\)) and use the same expression with that \(x\).
Moments (for the failures form): \(\mathbb{E}[X] = r\frac{1-p}{p}\), \(\mathrm{Var}(X) = r\frac{1-p}{p^2}\).
How to use this calculator
- Choose whether you model failures \(x\) or total trials \(n\). The two definitions are equivalent via \(x = n - r\).
- Enter \(r\) > 0 and \(p\) with \(0<p<1\). Non‑integer \(r\) is supported via the gamma function.
- Enter \(x\) (integer \(\ge 0\)) or \(n\) (integer \(\ge r\)), then click Compute PMF.
- Review the stepwise derivation and numeric result. Use Add to Table to collect scenarios.
- Export your table using Download CSV or Download PDF. Adjust precision for rounding as needed.
Notes
- We compute \(\log \Pr(X=x)\) using the log‑gamma function for stability: \(\log \Gamma(\cdot)\) avoids overflow in large factorial terms.
- The PMF is then obtained by exponentiation of the log result.
- The calculator supports real \(r\), which generalizes the combinatorial coefficient using gamma functions.
Example: Using Negative Binomial PDF/PMF Value
Scenario (failures form): \(r=5,\; p=0.40,\; x=3\). The probability is \(\Pr(X=3)=\binom{3+5-1}{3}(1-0.40)^3(0.40)^5 = 0.0774144\). The natural log is about \(-2.558582\). Moments: mean \(=7.5\), variance \(=18.75\).
Reference PMF Table (r = 5, p = 0.40)
Values for \(x=0,\dots,10\) under the failures parameterization.
| x | PMF | log PMF |
|---|
Parameterizations and Support
| Mode | Random Variable | Support | Mapping to failures \(x\) | PMF Form |
|---|---|---|---|---|
| Failures | \(X\) | \(0,1,2,\dots\) | \(x=X\) | \(\displaystyle \frac{\Gamma(x+r)}{\Gamma(r)\Gamma(x+1)}(1-p)^x p^r\) |
| Trials | \(N\) | \(r,r+1,r+2,\dots\) | \(x=N-r\) | \(\displaystyle \frac{\Gamma((N-r)+r)}{\Gamma(r)\Gamma((N-r)+1)}(1-p)^{N-r} p^r\) |
Moments and Dispersion Examples
For failures form: \(\mathbb{E}[X]=r\frac{1-p}{p}\), \(\mathrm{Var}(X)=r\frac{1-p}{p^2}\). The dispersion index \(\mathrm{Var}/\mathbb{E}\) indicates over-dispersion versus Poisson when \(>1\).
| r | p | Mean | Variance | Variance / Mean |
|---|