negativeBinomial
negativeBinomial, function
def pure negativeBinomial(mu: number, dispersion: number): ranvar
def pure negativeBinomial(mu: number, dispersion: number, zeroInflation: number): ranvar
Returns a negative binomial distribution with component mean mu and
dispersion dispersion. The zeroInflation overload mixes that distribution
with extra mass at zero.
mu: mean of the negative binomial component, must be positive. Without zero inflation, it is also the mean of the complete distribution.dispersion: variance divided by mean for the negative binomial component, must be >= 1.zeroInflation: extra mass at zero, in [0, 1].
Examples
table T = with
[| as Mu, as Dispersion |]
[| 2, 1.5 |]
[| 5, 2.0 |]
T.R = negativeBinomial(T.Mu, T.Dispersion)
show table "Negative binomial" with
T.Mu
T.Dispersion
mean(T.R) as "Mean"
This produces the following table:
| Mu | Dispersion | Mean |
|---|---|---|
| 2 | 1.5 | 1.999974 |
| 5 | 2 | 4.999969 |
table T = with
[| as Mu, as Dispersion, as ZeroInflation |]
[| 2, 1.5, 0.2 |]
T.R = negativeBinomial(T.Mu, T.Dispersion, T.ZeroInflation)
show table "Zero inflated" with
T.ZeroInflation
mean(T.R) as "Mean"
This produces the following table:
| ZeroInflation | Mean |
|---|---|
| 0.2 | 1.599979 |