Skip to main content

distributions.PiecewisePareto

Piecewise Pareto: alpha alpha[k] above threshold t[k], the

Usage

Source

distributions.PiecewisePareto()

general large-loss model and the result of tower matching.

Parameters

t: list of float

Strictly increasing positive thresholds.

alpha: list of float

One alpha per threshold; interior ones may be 0, the last must be positive.

truncation: float

Truncation point above the last threshold.

truncation_type: (lp, wd) = "lp"
Truncate the last piece only, or the whole distribution.

Raises

ValueError
If a parameter is out of range.

Examples

>>> from prospicio.distributions import PiecewisePareto
>>> pp = PiecewisePareto([1000.0, 2000.0], [1.0, 2.0])
>>> round(pp.survival(4000.0), 12)

0.125

Attributes

Name Description
alpha Alphas, one per threshold.
t Thresholds.
truncation Truncation point, or None.
truncation_type "lp" or "wd" when truncated, else None.

alpha

Alphas, one per threshold.

alpha: list[float]


t

Thresholds.

t: list[float]


truncation

Truncation point, or None.

truncation: float | None


truncation_type

"lp" or "wd" when truncated, else None.

truncation_type: str | None

Methods

Name Description
cdf() Distribution function P(X <= x).
fit() Maximum likelihood fit of the alphas for thresholds t to large
fit_with_standard_errors() PiecewisePareto.fit with the standard error of each alpha. The
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)].
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

fit()

Maximum likelihood fit of the alphas for thresholds t to large

Usage

Source

fit(
    losses,
    t,
    reporting_thresholds=None,
    censored=None,
    weights=None,
    truncation=None,
    truncation_type="lp"
)

losses at or above t[0].

Parameters
losses: list of float
t: list of float

Thresholds of the fitted distribution.

reporting_thresholds: list of float = None
censored: list of bool = None
weights: list of float = None
truncation: float = None
truncation_type: (lp, wd) = "lp"
Truncate the last piece only (each alpha a closed form or a one-dimensional solve), or the whole distribution (the alphas are coupled and solved together).
Returns
PiecewisePareto

fit_with_standard_errors()

PiecewisePareto.fit with the standard error of each alpha. The

Usage

Source

fit_with_standard_errors(
    losses,
    t,
    reporting_thresholds=None,
    censored=None,
    weights=None,
    truncation=None,
    truncation_type="lp"
)

likelihood separates by piece, so the alphas are uncorrelated: alpha_k / sqrt(n_k), n_k the uncensored weight ending in piece k (NaN where none does). A truncated last piece takes the truncated Pareto’s; truncation_type="wd" couples the alphas and is refused. Parameters as fit.

Returns
tuple of (PiecewisePareto, list of float)

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

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