Negative binomial distribution¶
There are several different ways to parameterize the negative binomial distribution. Here, the quantiles are the number of “successes” that occur when draws from a binomial distribution are made repeatedly until the number of “failures” drawn is r. p is the probability of drawing a “success”.
- mpsci.distributions.negative_binomial.cdf(k, r, p)¶
Cumulative distribution function of the negative binomial distribution.
- Parameters:
r (int) – Number of failures until the experiment is stopped.
p (float) – Probability of success.
- mpsci.distributions.negative_binomial.logpmf(k, r, p)¶
Log of the probability mass function of the negative binomial distribution.
- Parameters:
r (int) – Number of failures until the experiment is stopped.
p (float) – Probability of success.
- mpsci.distributions.negative_binomial.mean(r, p)¶
Mean of the negative binomial distribution.
- Parameters:
r (int) – Number of failures until the experiment is stopped.
p (float) – Probability of success.
- mpsci.distributions.negative_binomial.mle(x, *, counts=None, r=None, p=None, allow_noninteger_r=True)¶
Maximum likelihood estimation for the negative binomial distribution.
x must be a sequence of nonnegative integers.
- mpsci.distributions.negative_binomial.nll(x, r, p, *, counts=None)¶
Negative log-likelihood of sample for the negative binomial distribution.
- Parameters:
x (sequence of nonnegative integers) – The sample for which the negative log-likelihood is to be calculated.
r (int) – Number of failures until the experiment is stopped.
p (float) – Probability of success.
counts (sequence of integers, optional) – If given, this sequence must be the same length as x. It gives the number of occurrences in the sample of the corresponding value in x.
- mpsci.distributions.negative_binomial.pmf(k, r, p)¶
Probability mass function of the negative binomial distribution.
- Parameters:
r (int) – Number of failures until the experiment is stopped.
p (float) – Probability of success.
- mpsci.distributions.negative_binomial.sf(k, r, p)¶
Survival function of the negative binomial distribution.
- Parameters:
r (int) – Number of failures until the experiment is stopped.
p (float) – Probability of success.
- mpsci.distributions.negative_binomial.support(r, p)¶
Support of the negative binomial distribution.
The support is the integers 0, 1, 2, 3, …, so the support is returned as an instance of itertools.count(start=0).
Examples
>>> from mpsci.distributions import negative_binomial >>> sup = negative_binomial.support() >>> next(sup) 0 >>> next(sup) 1
- mpsci.distributions.negative_binomial.var(r, p)¶
Variance of the negative binomial distribution.
- Parameters:
r (int) – Number of failures until the experiment is stopped.
p (float) – Probability of success.