random.negativeBinomial
random.negativeBinomial, function
def pure random.negativeBinomial(mu: number, d: number): number
def pure random.negativeBinomial(mu: number, d: number, zeroInflation: number): number
Draws a deviate from a negative binomial distribution with mean mu and
dispersion d. The third-argument overload adds a zero-inflation mixture.
mu: the mean of the distribution (non-negative).d: the dispersion (must be at least 1).zeroInflation: the probability mass at zero, between 0 and 1.
Examples
montecarlo 10000 with
x = random.negativeBinomial(4, 1.5)
sample avgX = avg(x)
show scalar "Average sample" with avgX
This outputs the following scalar:
| Average sample |
|---|
| 3.9532 |
montecarlo 10000 with
y = random.negativeBinomial(4, 1.5, 0.2)
sample avgY = avg(y)
show scalar "Average sample (zero-inflated)" with avgY
This outputs the following scalar:
| Average sample (zero-inflated) |
|---|
| 3.2127 |
Remarks
When d equals 1, this function behaves like random.poisson(mu).