negativeBinomial
negativeBinomial, function
def pure negativeBinomial(mu: number, dispersion: number): ranvar
def pure negativeBinomial(mu: number, dispersion: number, zeroInflation: number): ranvar
Returns the negative binomial distribution with mean mu and dispersion
dispersion. The zeroInflation overload adds extra mass at zero.
mu: mean of the distribution, must be positive.dispersion: variance divided by mean, 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 |