{
  "id": "negative-binomial-distribution",
  "title": "Negative Binomial Distribution",
  "lang": "en",
  "source_lang": "en",
  "summary": "The negative binomial distribution models failures before a fixed number of successes and, more generally, count data whose variance exceeds their mean.",
  "category": "mathematics",
  "subcategory": "probability-statistics",
  "type": "concept",
  "aliases": [
    "Pascal distribution",
    "Pólya distribution",
    "Gamma–Poisson distribution"
  ],
  "generated_at": "2026-11-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/negative-binomial-distribution/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/negative-binomial-distribution/",
      "json": "https://aiwiki.page/zh/negative-binomial-distribution.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The negative binomial distribution is a discrete probability distribution on the nonnegative integers. In its classical interpretation, it describes the number of failures before a specified number of successes in independent trials with a constant success probability. A more general formulation permits a positive, noninteger shape parameter and arises as a mixture of Poisson distributions with gamma-distributed rates. This formulation makes the negative binomial an important model for count data whose variance exceeds their mean."
    },
    {
      "heading": "Definition and parameter conventions",
      "text": "Let \\(X\\) be the number of failures before the \\(r\\)th success, where each trial has success probability \\(p\\). Initially, take \\(r\\) to be a positive integer and \\(0<p<1\\). The probability mass function is\n\n\\[\\Pr(X=k) = \\binom{k+r-1}{k}p^r(1-p)^k, \\qquad k=0,1,2,\\ldots.\\]\n\nHere \\(r\\) is the required number of successes, and \\(k\\) counts failures. The binomial coefficient counts the ways to arrange \\(k\\) failures and \\(r-1\\) successes before the final, required success.\n\nThe distribution extends to every real \\(r>0\\) through the gamma function:\n\n\\[\\Pr(X=k) = \\frac{\\Gamma(k+r)}{\\Gamma(r)\\Gamma(k+1)} p^r(1-p)^k.\\]\n\nThe notation \\(X\\sim\\operatorname{NB}(r,p)\\) will refer here to this failures-counting convention. At \\(p=1\\), its natural extension is the degenerate distribution concentrated at zero.\n\nAlternative conventions\n\nParameter conventions differ substantially across textbooks and software.\n\n- Some definitions count the total number of trials, \\(T=X+r\\), rather than failures. For integer \\(r\\), its support is \\(r,r+1,\\ldots\\), and\n\n\\[\\Pr(T=t)=\\binom{t-1}{r-1}p^r(1-p)^{t-r}.\\]\n- Some authors interchange \\(p\\) and \\(1-p\\), so that \\(p\\) denotes the probability of a counted event rather than the stopping event.\n- Statistical models often use a mean and a dispersion parameter instead of \\(r\\) and \\(p\\).\n\nThe name Pascal distribution is commonly associated with the integer-shape case. Gamma–Poisson distribution emphasizes the mixture representation. The name Pólya distribution is also used, although naming conventions are not uniform."
    },
    {
      "heading": "Derivation from repeated trials",
      "text": "Consider a sequence of independent trials, each following a Bernoulli distribution with success probability \\(p\\).\n\nFor the \\(r\\)th success to occur after exactly \\(k\\) failures:\n\n- The first \\(k+r-1\\) trials must contain \\(r-1\\) successes and \\(k\\) failures.\n- The next trial must be a success.\n\nEvery such sequence has probability \\(p^r(1-p)^k\\), and there are \\(\\binom{k+r-1}{k}\\) possible initial arrangements. Multiplying these quantities gives the probability mass function.\n\nThis distinguishes the negative binomial from the binomial distribution. A binomial experiment fixes the number of trials and counts successes; a negative binomial experiment fixes the number of successes and counts failures, or equivalently the required number of trials.\n\nFor example, if each trial succeeds with probability \\(1/4\\), the probability of exactly two failures before the third success is\n\n\\[\\Pr(X=2) = \\binom{4}{2} \\left(\\frac14\\right)^3 \\left(\\frac34\\right)^2 = \\frac{27}{512}.\\]\n\nThe labels “success” and “failure” are mathematical conventions and need not indicate desirable or undesirable outcomes."
    },
    {
      "heading": "Why the distribution is called negative binomial",
      "text": "The name comes from the binomial expansion with a negative exponent. For \\(r>0\\),\n\n\\[(1-z)^{-r} = \\sum_{k=0}^{\\infty} \\frac{\\Gamma(k+r)}{\\Gamma(r)\\Gamma(k+1)}z^k, \\qquad |z|<1.\\]\n\nSubstituting \\(z=1-p\\) and multiplying by \\(p^r\\) shows that the probabilities sum to one.\n\nEquivalently, the generalized coefficients satisfy\n\n\\[(-1)^k\\binom{-r}{k} = \\frac{\\Gamma(k+r)}{\\Gamma(r)\\Gamma(k+1)}.\\]\n\nThus “negative” refers to the exponent or upper binomial argument, not to the possible values of the random variable, which are nonnegative."
    },
    {
      "heading": "Moments and generating function",
      "text": "Under the failures-counting convention, the expected value and variance are\n\n\\[\\operatorname{E}[X]=\\frac{r(1-p)}{p}, \\qquad \\operatorname{Var}(X)=\\frac{r(1-p)}{p^2}.\\]\n\nThe probability generating function is\n\n\\[G_X(s)=\\operatorname{E}[s^X] = \\left(\\frac{p}{1-(1-p)s}\\right)^r, \\qquad |s|<\\frac{1}{1-p}.\\]\n\nIts derivatives at \\(s=1\\) give the factorial moments:\n\n\\[\\operatorname{E}\\!\\left[X(X-1)\\cdots(X-m+1)\\right] = r(r+1)\\cdots(r+m-1) \\left(\\frac{1-p}{p}\\right)^m\\]\n\nfor positive integers \\(m\\).\n\nFor the total-trials convention,\n\n\\[\\operatorname{E}[T]=\\frac{r}{p}, \\qquad \\operatorname{Var}(T)=\\frac{r(1-p)}{p^2}.\\]\n\nThe shift changes the mean but not the variance.\n\nMean–dispersion parameterization\n\nWriting \\(\\mu=\\operatorname{E}[X]\\) gives\n\n\\[p=\\frac{r}{r+\\mu},\\]\n\nand therefore\n\n\\[\\Pr(X=k) = \\frac{\\Gamma(k+r)}{\\Gamma(r)\\Gamma(k+1)} \\left(\\frac{r}{r+\\mu}\\right)^r \\left(\\frac{\\mu}{r+\\mu}\\right)^k.\\]\n\nThe variance becomes\n\n\\[\\operatorname{Var}(X)=\\mu+\\frac{\\mu^2}{r}.\\]\n\nIf \\(\\alpha=1/r\\), this is\n\n\\[\\operatorname{Var}(X)=\\mu+\\alpha\\mu^2.\\]\n\nAt a fixed positive mean, smaller \\(r\\), or larger \\(\\alpha\\), produces greater dispersion. Since the variance exceeds the mean for finite \\(r\\), this parameterization is useful for overdispersed counts relative to a Poisson model."
    },
    {
      "heading": "Gamma–Poisson mixture representation",
      "text": "The negative binomial distribution can arise without any sequence of successes and failures.\n\nSuppose a count is conditionally Poisson:\n\n\\[X\\mid\\Lambda=\\lambda \\sim\\operatorname{Poisson}(\\lambda),\\]\n\nand its rate follows a gamma distribution with shape \\(r\\) and rate \\(\\beta\\):\n\n\\[f_\\Lambda(\\lambda) = \\frac{\\beta^r}{\\Gamma(r)} \\lambda^{r-1}e^{-\\beta\\lambda}, \\qquad \\lambda>0.\\]\n\nIntegrating over the unobserved rate gives\n\n\\[\\begin{aligned} \\Pr(X=k) &= \\int_0^\\infty \\frac{e^{-\\lambda}\\lambda^k}{k!} \\frac{\\beta^r}{\\Gamma(r)} \\lambda^{r-1}e^{-\\beta\\lambda} \\,d\\lambda\\\\ &= \\frac{\\Gamma(k+r)}{\\Gamma(r)k!} \\left(\\frac{\\beta}{\\beta+1}\\right)^r \\left(\\frac{1}{\\beta+1}\\right)^k. \\end{aligned}\\]\n\nThis is the negative binomial distribution with\n\n\\[p=\\frac{\\beta}{\\beta+1}.\\]\n\nThe representation explains why a negative binomial can model heterogeneous event rates. Even if observations are Poisson conditional on their individual rates, variation among those rates increases the marginal variance:\n\n\\[\\operatorname{Var}(X) = \\operatorname{E}[\\Lambda]+\\operatorname{Var}(\\Lambda).\\]\n\nIt also provides a simulation method: draw a gamma-distributed rate, then draw a Poisson count conditional on that rate.\n\nBayesian predictive interpretation\n\nIn Bayesian inference, the gamma distribution is a conjugate prior for a Poisson rate. Integrating a Poisson sampling model against a gamma posterior produces a negative binomial posterior predictive distribution.\n\nFor example, if the posterior rate is gamma with shape \\(a\\) and rate \\(b\\), a future count observed over exposure \\(t>0\\) has negative binomial parameters\n\n\\[r=a, \\qquad p=\\frac{b}{b+t}.\\]\n\nHere the negative binomial represents uncertainty about the future count after accounting for uncertainty in its underlying rate."
    },
    {
      "heading": "Related distributions and limiting behavior",
      "text": "Geometric special case\n\nWhen \\(r=1\\),\n\n\\[\\Pr(X=k)=p(1-p)^k.\\]\n\nThis is the failures-counting form of the geometric distribution. For integer \\(r\\), a negative binomial variable can be represented as the sum of \\(r\\) independent geometric variables with the same success probability.\n\nAddition with a common probability parameter\n\nIf independent variables satisfy\n\n\\[X_1\\sim\\operatorname{NB}(r_1,p), \\qquad X_2\\sim\\operatorname{NB}(r_2,p),\\]\n\nthen\n\n\\[X_1+X_2\\sim\\operatorname{NB}(r_1+r_2,p).\\]\n\nThis holds for arbitrary positive real shapes. It follows by multiplying their generating functions, or through convolution of their probability masses. The common value of \\(p\\) is essential: sums with different probability parameters are not generally negative binomial.\n\nPoisson limit\n\nHold \\(\\mu\\) fixed and let\n\n\\[r\\to\\infty, \\qquad p=\\frac{r}{r+\\mu}\\to1.\\]\n\nThen\n\n\\[\\operatorname{NB}(r,p) \\ \\xrightarrow{\\ d\\ }\\ \\operatorname{Poisson}(\\mu).\\]\n\nCorrespondingly, the variance \\(\\mu+\\mu^2/r\\) approaches \\(\\mu\\). The Poisson distribution is therefore a limiting case with vanishing extra dispersion.\n\nNormal approximation\n\nFor fixed \\(p\\), increasing \\(r\\) yields an approximately normal shape after standardization. For integer \\(r\\), this follows from the sum-of-geometric representation and the central limit theorem.\n\nA large mean alone does not guarantee a good normal approximation: with small fixed \\(r\\), substantial right skewness can persist even as the mean increases."
    },
    {
      "heading": "Parameter estimation",
      "text": "For independent observations \\(x_1,\\ldots,x_n\\), let \\(\\bar{x}\\) be the sample mean, and define the empirical second central moment\n\n\\[v=\\frac1n\\sum_{i=1}^n(x_i-\\bar{x})^2.\\]\n\nMatching empirical and theoretical moments gives\n\n\\[\\widehat p=\\frac{\\bar{x}}{v}, \\qquad \\widehat r=\\frac{\\bar{x}^2}{v-\\bar{x}},\\]\n\nprovided \\(v>\\bar{x}>0\\). Substituting an unbiased sample variance is another common finite-sample convention.\n\nIf the empirical variance does not exceed the mean, these formulas do not yield a finite positive shape estimate. This does not make such a sample impossible under a negative binomial model, but it limits the usefulness of this moment-matching procedure.\n\nFor maximum likelihood estimation, the log-likelihood function is\n\n\\[\\ell(r,p) = \\sum_{i=1}^n \\left[ \\log\\Gamma(x_i+r) -\\log\\Gamma(r) -\\log(x_i!) +r\\log p+x_i\\log(1-p) \\right].\\]\n\nFor fixed \\(r\\), its maximizing value of \\(p\\) is\n\n\\[\\widehat p(r)=\\frac{r}{r+\\bar{x}}.\\]\n\nEstimation of \\(r\\) generally requires numerical optimization. When the fitted extra dispersion approaches zero, \\(r\\) tends toward infinity and the model approaches the Poisson boundary."
    },
    {
      "heading": "Negative binomial regression",
      "text": "Negative binomial regression relates the mean count to explanatory variables, commonly through\n\n\\[\\log\\mu_i=\\mathbf{x}_i^\\top\\boldsymbol{\\beta}, \\qquad \\operatorname{Var}(Y_i\\mid\\mathbf{x}_i) = \\mu_i+\\alpha\\mu_i^2.\\]\n\nIt is widely used within the generalized linear model framework. The log link keeps fitted means positive and gives exponentiated coefficients a multiplicative interpretation.\n\nWhen counts refer to different exposures, such as different observation periods, a model may include an exposure offset:\n\n\\[\\log\\mu_i = \\log t_i+\\mathbf{x}_i^\\top\\boldsymbol{\\beta},\\]\n\nwhere \\(t_i\\) is the exposure and its log has coefficient fixed at one.\n\nThe quadratic variance formulation is often called NB2. Another specification, NB1, uses\n\n\\[\\operatorname{Var}(Y_i\\mid\\mathbf{x}_i) = \\mu_i(1+\\alpha).\\]\n\nBoth can use negative binomial conditional distributions, but they impose different relationships between mean and dispersion across observations. In NB2 the shape is constant when \\(\\alpha\\) is constant; in NB1 the shape varies with the mean."
    },
    {
      "heading": "Applications and limitations",
      "text": "Negative binomial models appear in ecology, insurance, traffic analysis, econometrics, and sequencing-based studies of gene expression. Their common role is to describe counts with more variability than a Poisson model permits.\n\nSeveral distinctions matter when interpreting such models:\n\n- Overdispersion does not identify its cause. Unobserved rate heterogeneity is one explanation, but omitted predictors, dependence, or an incorrect mean model can also produce it.\n- Dispersion does not automatically model dependence. Independent negative binomial observations remain independent. Repeated measurements, clusters, or a time series may require additional dependence structure.\n- Extra zeros do not necessarily imply a separate zero-generating process. A negative binomial can already assign substantial probability to zero. Zero-inflated or hurdle models introduce additional assumptions rather than merely allowing a larger variance.\n- Underdispersion is outside the standard family. A negative binomial count with positive mean cannot have variance below its mean.\n- Sampling restrictions change the distribution. If zero counts are unobservable, the appropriate likelihood is zero-truncated rather than the ordinary negative binomial likelihood.\n- Equal means and variances do not establish distributional fit. Tail behavior, zero frequencies, and conditional patterns can differ between distributions with similar first two moments."
    }
  ],
  "links": [
    "probability-distribution",
    "probability-mass-function",
    "binomial-coefficient",
    "gamma-function",
    "statistical-independence",
    "bernoulli-distribution",
    "binomial-distribution",
    "random-variable",
    "expected-value",
    "variance",
    "generating-function",
    "bayesian-inference",
    "conjugate-prior",
    "posterior-predictive-distribution",
    "convolution",
    "poisson-distribution",
    "normal-distribution",
    "central-limit-theorem",
    "sample-mean",
    "maximum-likelihood-estimation",
    "likelihood-function",
    "generalized-linear-model",
    "econometrics",
    "gene-expression",
    "time-series"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}