distributions.NegativeBinomial

Negative binomial claim counts: mean r * beta, variance

Usage

distributions.NegativeBinomial()

r * beta * (1 + beta) (Klugman, Panjer & Willmot).

SciPy’s nbinom(n=r, p=1/(1+beta)) is the same distribution.

Parameters

r: float

Shape; must be positive.

beta: float
Scale; must be positive.

Raises

ValueError
If r or beta is not positive and finite.

Examples

>>> from prospicio.distributions import NegativeBinomial
>>> n = NegativeBinomial.from_mean_variance(10.0, 30.0)
>>> round(n.variance(), 9)

30.0

Attributes

Name Description
beta Scale beta.
r Shape r.

beta

Scale beta.

beta: float


r

Shape r.

r: float

Methods

Name Description
cdf() P(N <= k).
from_mean_variance() The negative binomial with this mean and variance.
mean() Mean of the claim count.
pmf() P(N = k).
quantile() Smallest k with P(N <= k) >= p.
sample() n claim counts from stream stream of the generator keyed by
variance() Variance of the claim count.

cdf()

P(N <= k).

Usage

cdf(k)
Parameters
k: int
Returns
float

from_mean_variance()

The negative binomial with this mean and variance.

Usage

from_mean_variance(mean, variance)
Parameters
mean: float

Must be positive.

variance: float
Must exceed the mean.
Returns
NegativeBinomial
Raises
ValueError
If the mean is not positive or the variance does not exceed it.

mean()

Mean of the claim count.

Usage

mean()
Returns
float

pmf()

P(N = k).

Usage

pmf(k)
Parameters
k: int
Returns
float

quantile()

Smallest k with P(N <= k) >= p.

Usage

quantile(p)
Parameters
p: float
Probability in [0, 1).
Returns
int
Raises
ValueError
If p is outside [0, 1].

sample()

n claim counts from stream stream of the generator keyed by

Usage

sample(n, seed, stream=0)

seed.

Parameters
n: int
seed: int
stream: int = 0
Returns
list of int

variance()

Variance of the claim count.

Usage

variance()
Returns
float