Skip to main content

distributions.Ogive

An ogive: the piecewise linear distribution function through tabulated

Usage

Source

distributions.Ogive()

points (x, F(x)), the usual reading of grouped loss data (losses uniform within each band), as in Pricing Insurance Risk, Exercise 50.

Its limited moments are exact, band by band. Build one from grouped counts with Ogive.from_counts().

Parameters

x: list of float

At least two band boundaries, finite, non-negative and strictly increasing.

cdf: list of float
F at each boundary, non-decreasing from 0 to 1.

Raises

ValueError
If the table breaks any of these.

Examples

>>> from prospicio.distributions import Ogive
>>> o = Ogive.from_counts([0, 1000, 5000, 10000], [40, 50, 10])
>>> o.cdf(3000.0), round(o.quantile(0.95), 6), round(o.tvar(0.95), 6)

(0.65, 7500.0, 8750.0)

Attributes

Name Description
cdf_values F at the boundaries.
x The band boundaries.

cdf_values

F at the boundaries.

cdf_values: list[float]


x

The band boundaries.

x: list[float]

Methods

Name Description
cdf() P(X <= x), linear between the boundaries.
from_counts() The ogive of grouped data: counts[k] losses (or any weights)
layer() Expected 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() The mean.
pdf() The density, constant on each band and 0 outside.
quantile() The lower quantile, the smallest x with F(x) >= p.
sample() n draws from stream stream of the generator keyed by seed.
std_dev() The standard deviation.
survival() P(X > x).
tvar() Tail value at risk at p, the mean of the worst 1 - p.
variance() The variance.

cdf()

P(X <= x), linear between the boundaries.

Usage

Source

cdf(x)
Parameters
x: float
Returns
float

from_counts()

The ogive of grouped data: counts[k] losses (or any weights)

Usage

Source

from_counts(bounds, counts)

between bounds[k] and bounds[k + 1], spread uniformly.

Parameters
bounds: list of float

One more than the counts.

counts: list of float
Non-negative, with a positive total.
Returns
Ogive

layer()

Expected loss to the layer limit xs attachment.

Usage

Source

layer(limit, attachment)
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()

The mean.

Usage

Source

mean()
Returns
float

pdf()

The density, constant on each band and 0 outside.

Usage

Source

pdf(x)
Parameters
x: float
Returns
float

quantile()

The lower quantile, the smallest x with F(x) >= p.

Usage

Source

quantile(p)
Parameters
p: float
In [0, 1].
Returns
float

sample()

n draws from stream stream of the generator keyed by seed.

Usage

Source

sample(n, seed, stream=0)
Parameters
n: int
seed: int
stream: int = 0
Returns
list of float

std_dev()

The standard deviation.

Usage

Source

std_dev()
Returns
float

survival()

P(X > x).

Usage

Source

survival(x)
Parameters
x: float
Returns
float

tvar()

Tail value at risk at p, the mean of the worst 1 - p.

Usage

Source

tvar(p)
Parameters
p: float
In [0, 1).
Returns
float

variance()

The variance.

Usage

Source

variance()
Returns
float