Skip to main content

distributions.Lognormal

Lognormal distribution: ln X ~ Normal(meanlog, sdlog**2).

Usage

Source

distributions.Lognormal()

Parameters

meanlog: float

Mean of ln X.

sdlog: float
Standard deviation of ln X; must be positive.

Raises

ValueError
If meanlog is not finite or sdlog is not positive and finite.

Examples

>>> from prospicio.distributions import Lognormal
>>> d = Lognormal.from_mean_cv(1000.0, 0.5)
>>> round(d.mean(), 6)

1000.0

Attributes

Name Description
meanlog Mean of ln X.
sdlog Standard deviation of ln X.

meanlog

Mean of ln X.

meanlog: float


sdlog

Standard deviation of ln X.

sdlog: float

Methods

Name Description
cdf() Distribution function P(X <= x).
from_mean_cv() Lognormal with the given mean and coefficient of variation.
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,
lev() Limited expected value E[min(X, limit)].
mean() Mean of the distribution.
quantile() Quantile: the smallest x with P(X <= x) >= p.
sample() n draws from stream stream of the generator keyed by seed.
std() Standard deviation of the distribution.
stop_loss() Expected excess over a retention, E[max(X - retention, 0)],
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.

cdf()

Distribution function P(X <= x).

Usage

Source

cdf(x)
Parameters
x: float
Returns
float

from_mean_cv()

Lognormal with the given mean and coefficient of variation.

Usage

Source

from_mean_cv(mean, cv)
Parameters
mean: float

Mean of X; must be positive.

cv: float
Coefficient of variation of X; must be positive.
Returns
Lognormal
Raises
ValueError
If mean or cv is not positive and finite.

layer()

Expected loss to the layer limit xs attachment.

Usage

Source

layer(limit, attachment)
Parameters
limit: float
attachment: float
Returns
float
Examples
>>> from prospicio.distributions import Lognormal
>>> d = Lognormal(7.0, 0.5)
>>> abs(d.layer(1000.0, 0.0) - d.lev(1000.0)) < 1e-9

True


layer_second_moment()

Second moment of the loss to the layer limit xs

Usage

Source

layer_second_moment(limit, attachment)

attachment, in closed form.

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

lev()

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

Usage

Source

lev(limit)
Parameters
limit: float
Returns
float

mean()

Mean of the distribution.

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]; quantile(1.0) is inf.
Returns
float
Raises
ValueError
If p is outside [0, 1].

sample()

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

Usage

Source

sample(n, seed, stream=0)

The same (seed, stream) gives the same draws in Python, R and Rust.

Parameters
n: int

Number of draws.

seed: int

Generator seed.

stream: int = 0
Stream id; distinct streams are independent.
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)

accurate far into the tail.

Parameters
retention: 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.

Usage

Source

variance()
Returns
float