Skip to main content

distributions.Tweedie

Tweedie distribution with mean mu, dispersion phi and power

Usage

Source

distributions.Tweedie()

1 < p < 2: variance phi * mu**p, a point mass at 0 and a continuous density above it.

It is a Poisson number of gamma losses, the GLM family for pure premium. P(Y = 0) = exp(-lambda_).

Parameters

mean: float
dispersion: float
power: float
In (1, 2).

Raises

ValueError
If a parameter is out of range.

Examples

>>> import math
>>> from prospicio.distributions import Tweedie
>>> y = Tweedie(500.0, 40.0, 1.6)
>>> abs(y.cdf(0.0) - math.exp(-y.lambda_)) < 1e-15

True

Attributes

Name Description
cv Coefficient of variation sqrt(phi) * mu**(p/2 - 1).
dispersion Dispersion phi.
lambda_ Poisson mean of the number of losses.
p0 Probability of no loss, exp(-lambda_).
power Power p.
severity The gamma distribution of each loss.
severity_cv Coefficient of variation of each gamma loss.
severity_mean Mean of each gamma loss, mu / lambda_.

cv

Coefficient of variation sqrt(phi) * mu**(p/2 - 1).

cv: float


dispersion

Dispersion phi.

dispersion: float


lambda_

Poisson mean of the number of losses.

lambda_: float


p0

Probability of no loss, exp(-lambda_).

p0: float


power

Power p.

power: float


severity

The gamma distribution of each loss.

severity: Gamma


severity_cv

Coefficient of variation of each gamma loss.

severity_cv: float


severity_mean

Mean of each gamma loss, mu / lambda_.

severity_mean: float

Methods

Name Description
cdf() Distribution function P(X <= x).
from_compound() The Tweedie equal to a Poisson number of losses with mean
from_cv() The Tweedie with power power, mean mean and coefficient of
from_cv_dispersion() The Tweedie with mean mean, coefficient of variation cv and
from_poisson_gamma() The Tweedie equal to a Poisson(lambda_) number of
layer() Expected loss to the layer limit xs attachment.
layer_second_moment() Second moment of the loss to the layer limit xs
layer_third_moment() Third moment of the loss to the layer limit xs attachment,
layer_variance() Variance of the loss to the layer limit xs attachment.
lev() Limited expected value E[min(X, limit)].
ln_pdf() Log density at y > 0; at y = 0, the log of the point mass.
mean() Mean of the distribution (inf if it does not exist).
quantile() Quantile: the smallest x with P(X <= x) >= p.
sample() n draws from stream stream of the generator keyed by
std() Standard deviation of the distribution.
stop_loss() Expected excess over a retention, E[max(X - retention, 0)].
survival() Survival function P(X > x), accurate far into the tail.
tvar() Tail value at risk at p in [0, 1), the mean of the worst
var() Value at risk, the lower quantile at p: the same as quantile.
variance() Variance of the distribution (inf if it does not exist).

cdf()

Distribution function P(X <= x).

Usage

Source

cdf(x)
Parameters
x: float
Returns
float

from_compound()

The Tweedie equal to a Poisson number of losses with mean

Usage

Source

from_compound(frequency, severity_mean, severity_cv)

frequency and a gamma severity with mean severity_mean and coefficient of variation severity_cv, as aggregate’s TweedieConversion.from_compound.

Parameters
frequency: float
severity_mean: float
severity_cv: float
Returns
Tweedie
Examples
>>> from prospicio.distributions import Tweedie
>>> y = Tweedie.from_compound(10.0, 10.0, 1.0)
>>> round(y.power, 12), round(y.dispersion, 12)

(1.5, 2.0)


from_cv()

The Tweedie with power power, mean mean and coefficient of

Usage

Source

from_cv(power, mean, cv)

variation cv (of the Tweedie, not of its severity): dispersion cv**2 * mean**(2 - power), as aggregate’s TweedieConversion.from_cv.

Parameters
power: float

In (1, 2).

mean: float
cv: float
Returns
Tweedie
Examples
>>> from prospicio.distributions import Tweedie
>>> round(Tweedie.from_cv(1.5, 100.0, 0.5).dispersion, 12)

2.5


from_cv_dispersion()

The Tweedie with mean mean, coefficient of variation cv and

Usage

Source

from_cv_dispersion(mean, cv, dispersion)

dispersion dispersion: the power 2 + log(cv**2 / dispersion) / log(mean), which must lie in (1, 2).

Parameters
mean: float

Not 1.

cv: float
dispersion: float
Returns
Tweedie
Examples
>>> from prospicio.distributions import Tweedie
>>> round(Tweedie.from_cv_dispersion(100.0, 0.5, 2.5).power, 12)

1.5


from_poisson_gamma()

The Tweedie equal to a Poisson(lambda_) number of

Usage

Source

from_poisson_gamma(lambda_, shape, scale)

Gamma(shape, scale) losses.

Parameters
lambda_: float
shape: float
scale: float
Returns
Tweedie

layer()

Expected loss to the layer limit xs attachment.

Usage

Source

layer(limit, attachment)
Parameters
limit: float

inf for an unlimited layer.

attachment: float
Returns
float

layer_second_moment()

Second moment of the loss to the layer limit xs

Usage

Source

layer_second_moment(limit, attachment)
Parameters
limit: float
attachment: float
Returns
float

layer_third_moment()

Third moment of the loss to the layer limit xs attachment,

Usage

Source

layer_third_moment(limit, attachment)

E[min(max(X - a, 0), l)^3], by quadrature of the survival function (relative accuracy about 1e-10); limit = inf for the unlimited layer, attachment = 0 for the limited third moment.

Parameters
limit: float
attachment: float
Returns
float

layer_variance()

Variance of the loss to the layer limit xs attachment.

Usage

Source

layer_variance(limit, attachment)
Parameters
limit: float
attachment: float
Returns
float

lev()

Limited expected value E[min(X, limit)].

Usage

Source

lev(limit)
Parameters
limit: float
Returns
float

ln_pdf()

Log density at y > 0; at y = 0, the log of the point mass.

Usage

Source

ln_pdf(y)
Parameters
y: float
Returns
float

mean()

Mean of the distribution (inf if it does not exist).

Usage

Source

mean()
Returns
float

quantile()

Quantile: the smallest x with P(X <= x) >= p.

Usage

Source

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

sample()

n draws from stream stream of the generator keyed by

Usage

Source

sample(n, seed, stream=0)

seed.

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

std()

Standard deviation of the distribution.

Usage

Source

std()
Returns
float

stop_loss()

Expected excess over a retention, E[max(X - retention, 0)].

Usage

Source

stop_loss(retention)
Parameters
retention: float
Returns
float

survival()

Survival function P(X > x), accurate far into the tail.

Usage

Source

survival(x)
Parameters
x: float
Returns
float

tvar()

Tail value at risk at p in [0, 1), the mean of the worst

Usage

Source

tvar(p)

1 - p: VaR(p) + E[(X - VaR(p))+] / (1 - p); inf where the mean is.

Parameters
p: float
Returns
float

var()

Value at risk, the lower quantile at p: the same as quantile.

Usage

Source

var(p)
Parameters
p: float
Returns
float

variance()

Variance of the distribution (inf if it does not exist).

Usage

Source

variance()
Returns
float