11 / Distributions
Negative binomial: repeated-success targets and overdispersed counts
A negative-binomial distribution can model failures before a target number of successes. A related parameterisation also describes count data whose variance exceeds its mean. State which interpretation is being used before calculating.
The business question
How variable is the effort needed to achieve several successes?
- Explore contacts required to reach several conversions in a comparable-trial scenario.
- Model suitable overdispersed incident or demand counts when a Poisson variance is too restrictive.
- Make dispersion explicit when planning resources against a count tail.
How the method works
In the repeated-trial interpretation, specify a target r successes and a constant independent success probability p. The random variable F counts failures before the rth success. The last trial must be a success; among the preceding trials, successes and failures can occur in many arrangements. SciPy’s nbinom uses this failure-count variable rather than the total number of attempts.
The mean number of failures is r(1 − p)/p, and the total number of attempts is F + r. The failure-count variance is r(1 − p)/p², which can be much larger than the mean. Convert a total-attempt budget into a failure budget before asking for a cumulative probability. This avoids reporting a mathematically valid probability for the wrong business question.
For fixed-window count modelling, another common form uses a mean μ and a dispersion parameter r, giving variance μ + μ²/r and p = r/(r + μ). This does not require interpreting every count as literal failed sales attempts. It can represent extra count variability, but a statistical fit alone does not identify its business cause. Investigate changing exposure, mixed rates and dependence before selecting it merely because it produces a convenient tail.
The calculation
| Symbol | Meaning |
|---|---|
| r | Required successes in the repeated-trial example; a positive dispersion/shape parameter in the count parameterisation. |
| p | Success probability in the repeated-trial interpretation. |
| F | Non-negative failures before the rth success, not total attempts. |
| μ | Mean count when using the alternative variance μ + μ²/r form. |
A worked business example
ILLUSTRATIVE SCENARIO
Illustrative sales desk wants five conversions. The planning scenario assumes independent contacts with a 25% conversion probability. The manager asks whether a twenty-contact allocation is enough to reach the target.
Inputs
- Target r = 5 successes; p = 0.25 per contact.
- Total contact budget = 20.
- Every contact has one success/failure outcome in this simplified scenario.
Work through the numbers
- Expected failures = 5 × 0.75/0.25 = 15. Expected total contacts = 15 + 5 = 20.
- Variance of failures = 5 × 0.75/0.25² = 60. Adding five fixed successes does not change the variance of total attempts.
- Achieving the fifth success by contact twenty requires no more than 20 − 5 = 15 failures before that success.
- Calculate P(F ≤ 15) using nbinom with r = 5 and p = 0.25: 0.5851585.
The mean effort is not a high-coverage quota. A manager who needs a much higher chance of meeting the conversion target must compare larger contact budgets or a different feasible process.
Explore the decision
Count failures before several successes. The live explorer has its own example inputs; it is separate from the worked calculation above.
Enable JavaScript to use this calculator. The worked example and executable Python remain available.
Apply it at work
- Choose either the repeated-success or fixed-window count interpretation and name the random variable.
- Estimate parameters from relevant opportunities or counts, with their exposure and subgroup definitions.
- Convert business thresholds into the model’s variable, then calculate the required tail or percentile.
- Validate predicted variation and check whether changing rates or dependence require a more explicit model.
Check these assumptions
- The worked trial example uses independent contacts with constant p.
- The success target is fixed and the variable counts failures until it is reached.
- Fixed-window uses need comparable exposure or a model that adjusts for exposure.
- Parameter uncertainty and future changes in the conversion process are not included in the numerical example.
Common mistakes and how to avoid them
- Passing a twenty-contact total directly as a failure count overstates the probability of meeting the target.
- Overdispersion is a symptom to understand, not proof that a specific negative-binomial mechanism generated the records.
- A good fit to an aggregate count can conceal different customer groups or predictable peak periods.
How this can help the business
- Effort allocations can be based on target-achievement probability rather than a misleading expected quota.
- A count forecast can acknowledge excess variability and avoid overstating the protection offered by an average-demand plan.
Use a threshold probability for the correctly defined count and select an operationally defensible parameterisation; test the fit against held-out periods or contacts.
When to use another approach
Use binomial for a fixed number of trials, Poisson for suitable equidispersed event counts, or a regression model when count rates depend on measured drivers.
Reproduce the worked example in Python
The code is self-contained for this example. Dependencies and run instructions are included with the downloadable notebook.
Show executable code and recorded output
from scipy.stats import nbinom
r, p = 5, 0.25
contact_budget = 20
failure_budget = contact_budget-r
print(f'Expected total contacts: {nbinom.mean(r,p)+r:.2f}')
print(f'Contact-count variance: {nbinom.var(r,p):.2f}')
print(f'Five successes by contact 20: {nbinom.cdf(failure_budget,r,p):.2%}')Recorded output
Expected total contacts: 20.00 Contact-count variance: 60.00 Five successes by contact 20: 58.52%
Sources and further reading
Concepts are linked to primary teaching or technical sources. The business examples are illustrative applications, not reported client results.