Skip to content

Revamp our negative binomial explanation (#5300) #5365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions pymc/distributions/discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand Down Expand Up @@ -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. and 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
Expand Down