From eb5177a5bb97a437870727906fc52acf29dc53d2 Mon Sep 17 00:00:00 2001 From: herve-91 <76769960+herve-91@users.noreply.github.com> Date: Sun, 23 Jan 2022 13:22:27 +0100 Subject: [PATCH] Revamp our negative binomial explanation (#5365) Closes #5300 Co-authored-by: Michael Osthege --- pymc/distributions/discrete.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pymc/distributions/discrete.py b/pymc/distributions/discrete.py index 952137f0dc1..74432f90f05 100644 --- a/pymc/distributions/discrete.py +++ b/pymc/distributions/discrete.py @@ -650,7 +650,7 @@ class NegativeBinomial(Discrete): The negative binomial distribution describes a Poisson random variable whose rate parameter is gamma distributed. - The pmf of this distribution is + Its pmf, parametrized by the parameters alpha and mu of the gamma distribution, is .. math:: @@ -692,15 +692,24 @@ def NegBinom(a, m, x): .. math:: - \mu &= \frac{n(1-p)}{p} \\ - \alpha &= n + p &= \frac{\alpha}{\mu + \alpha} \\ + n &= \alpha + + If it is parametrized in terms of n and p, the negative binomial describes the probability to have x failures + before the n-th success, given the probability p of success in each trial. Its pmf is + + .. math:: + + f(x \mid n, p) = + \binom{x + n - 1}{x} + (p)^n (1 - p)^x Parameters ---------- - mu: float - Poission distribution parameter (mu > 0). alpha: float - Gamma distribution parameter (alpha > 0). + Gamma distribution shape parameter (alpha > 0). + mu: float + Gamma distribution mean (mu > 0). p: float Alternative probability of success in each trial (0 < p < 1). n: float