Skip to main content

risk.Distortion

A distortion risk measure: rho(X) = integral of g(S(x)) dx for a

Usage

Source

risk.Distortion()

Examples

>>> from prospicio.distributions import Sampled
>>> from prospicio.risk import Distortion
>>> x = Sampled([1.0, 2.0, 3.0, 4.0])
>>> Distortion.tvar(0.5).measure(x)

3.5

>>> Distortion.tvar(0.5).weights(4)

[0.0, 0.0, 0.5, 0.5]

Attributes

Name Description
family The family, as its constructor is named, for example
gini The Gini index 2 * integral of g - 1: 0 for the mean and 1 for the
mass The probability mass on the largest outcome, g(0+).
parameter The parameter of a family with one, such as the proportional
parameters The scalar parameters by name, as the constructor takes them, for

family

The family, as its constructor is named, for example

family: str

"proportional_hazard" or "capped_linear".


gini

The Gini index 2 * integral of g - 1: 0 for the mean and 1 for the

gini: float

maximum, and the level of the TVaR that prices a uniform loss as this distortion does (aggregate’s gini).

Examples
>>> from prospicio.risk import Distortion
>>> Distortion.tvar(0.9).gini, round(Distortion.proportional_hazard(0.5).gini, 12)

(0.9, 0.333333333333)


mass

The probability mass on the largest outcome, g(0+).

mass: float


parameter

The parameter of a family with one, such as the proportional

parameter: float | None

hazard’s rho; None for a family with several or none.

Examples
>>> from prospicio.risk import Distortion
>>> Distortion.wang(0.3).parameter, Distortion.lep(0.05, 0.1).parameter

(0.3, None)


parameters

The scalar parameters by name, as the constructor takes them, for

parameters: dict[str, float]

example {"rho": 0.7}; empty for weighted TVaR, mixtures, minimums and convex envelopes, whose inputs are lists.

Examples
>>> from prospicio.risk import Distortion
>>> d = Distortion.proportional_hazard(0.7)
>>> d.family, d.parameters

(‘proportional_hazard’, {‘rho’: 0.7})

Methods

Name Description
beta() The Beta(a, b) distribution function, concave for a <= 1 <= b.
bitvar() Weight 1 - w on TVaR(p0) and w on TVaR(p1).
capped_linear() Capped linear: g(s) = min(1, r0 + slope s) for s > 0.
capped_log_linear() Capped log-linear: g(s) = min(1, exp(r0) s**b).
ccoc() Constant cost of capital r: g(s) = min(1, d + (1 - d) s) for
convex() The smallest concave distortion above the points (s, g), for
dual_power() Dual power transform: g(s) = 1 - (1 - s)**beta.
exponential() Exponential spectral measure: g(s) = (1 - exp(-k s)) / (1 - exp(-k)),
from_gini() The member of a one-parameter family with Gini index gini.
g() The distortion g(s) of a survival probability s.
g_dual() The dual distortion 1 - g(1 - s), which gives the bid.
g_inv() The smallest s with g(s) >= y.
lep() Leverage-equivalent pricing:
linear_yield() Linear yield: g(s) = (r0 + (1 + r) s) / (1 + r0 + r s).
measure() The risk measure of a distribution.
minimum() The pointwise minimum of distortions.
mixture() A weighted average of distortions.
proportional_hazard() Proportional hazard transform: g(s) = s**rho.
tsallis() Tsallis distortion of order alpha, the Beta(alpha, 1) mixture of
tvar() Tail value at risk at level p: g(s) = min(s / (1 - p), 1).
wang() Wang transform: g(s) = Phi(Phi^-1(s) + lambda).
weighted_tvar() A weighted average of TVaRs.
weights() Weights for n equally likely values sorted ascending.

beta()

The Beta(a, b) distribution function, concave for a <= 1 <= b.

Usage

Source

beta(a, b)
Parameters
a: float

In (0, 1].

b: float
>= 1.
Returns
Distortion

bitvar()

Weight 1 - w on TVaR(p0) and w on TVaR(p1).

Usage

Source

bitvar(p0, p1, w)
Parameters
p0: float

Levels with 0 <= p0 <= p1 <= 1.

p1: float

Levels with 0 <= p0 <= p1 <= 1.

w: float
Weight on TVaR(p1), in [0, 1].
Returns
Distortion

capped_linear()

Capped linear: g(s) = min(1, r0 + slope s) for s > 0.

Usage

Source

capped_linear(r0, slope)
Parameters
r0: float

Mass on the largest outcome, in [0, 1).

slope: float
With r0 + slope >= 1.
Returns
Distortion

capped_log_linear()

Capped log-linear: g(s) = min(1, exp(r0) s**b).

Usage

Source

capped_log_linear(r0, b)
Parameters
r0: float

>= 0.

b: float
In (0, 1].
Returns
Distortion

ccoc()

Constant cost of capital r: g(s) = min(1, d + (1 - d) s) for

Usage

Source

ccoc(r)

s > 0, d = r / (1 + r). The price is (E[X] + r max X) / (1 + r).

Parameters
r: float
Return on capital, >= 0.
Returns
Distortion

convex()

The smallest concave distortion above the points (s, g), for

Usage

Source

convex(points)

example layers’ exceedance probabilities and their prices per unit of limit (a cat bond’s expected loss and spread).

Parameters
points: list of (float, float)
In the unit square, with g >= s.
Returns
Distortion
Examples
>>> from prospicio.risk import Distortion
>>> Distortion.convex([(0.1, 0.3), (0.5, 0.55)]).g(0.05)

0.15


dual_power()

Dual power transform: g(s) = 1 - (1 - s)**beta.

Usage

Source

dual_power(beta)
Parameters
beta: float
>= 1.
Returns
Distortion

exponential()

Exponential spectral measure: g(s) = (1 - exp(-k s)) / (1 - exp(-k)),

Usage

Source

exponential(k)

risk aversion that grows exponentially towards the worst outcomes.

Parameters
k: float
Risk aversion, positive; the mean as k -> 0.
Returns
Distortion

from_gini()

The member of a one-parameter family with Gini index gini.

Usage

Source

from_gini(family, gini)
Parameters
family: str

"ccoc", "ph", "wang", "tsallis", "dual", "tvar" or "exp".

gini: float
In (0, 1): 0 is the mean and 1 the maximum.
Returns
Distortion
The members of the families with one index price a uniform loss alike, at (1 + gini) / 2.
Examples
>>> from prospicio.risk import Distortion
>>> Distortion.from_gini("tsallis", 0.25)

Distortion.tsallis(3.0)

>>> round(Distortion.from_gini("ph", 0.25).parameter, 12)

0.6


g()

The distortion g(s) of a survival probability s.

Usage

Source

g(s)
Parameters
s: float
Returns
float

g_dual()

The dual distortion 1 - g(1 - s), which gives the bid.

Usage

Source

g_dual(s)
Parameters
s: float
Returns
float

g_inv()

The smallest s with g(s) >= y.

Usage

Source

g_inv(y)
Parameters
y: float
Returns
float

lep()

Leverage-equivalent pricing:

Usage

Source

lep(r0, r)

g(s) = min(1, d + (1 - d) s + (delta - d) sqrt(s (1 - s))) with d = r0 / (1 + r0) and delta = r / (1 + r).

Parameters
r0: float

Minimum rate on line, >= 0.

r: float
Target return, >= r0.
Returns
Distortion

linear_yield()

Linear yield: g(s) = (r0 + (1 + r) s) / (1 + r0 + r s).

Usage

Source

linear_yield(r0, r)
Parameters
r0: float

Both >= 0.

r: float
Both >= 0.
Returns
Distortion

measure()

The risk measure of a distribution.

Usage

Source

measure(dist)
Parameters
dist: (Sampled, Grid or PredictiveDistribution)
A predictive distribution is measured on its total.
Returns
float

minimum()

The pointwise minimum of distortions.

Usage

Source

minimum(distortions)
Parameters
distortions: list of Distortion
Returns
Distortion

mixture()

A weighted average of distortions.

Usage

Source

mixture(distortions, weights)
Parameters
distortions: list of Distortion
weights: list of float
Non-negative, summing to 1.
Returns
Distortion

proportional_hazard()

Proportional hazard transform: g(s) = s**rho.

Usage

Source

proportional_hazard(rho)
Parameters
rho: float
In (0, 1].
Returns
Distortion

tsallis()

Tsallis distortion of order alpha, the Beta(alpha, 1) mixture of

Usage

Source

tsallis(alpha)

TVaRs: g(s) = (alpha s - s**alpha) / (alpha - 1), and s (1 - log s) at alpha = 1. Its price is the mean plus the cumulative residual Tsallis entropy of order alpha; alpha = 2 is dual_power(2) and the Gini index is 1 / (alpha + 1).

Parameters
alpha: float
Positive; the mean as alpha -> inf, the maximum as alpha -> 0.
Returns
Distortion
Examples
>>> from prospicio.risk import Distortion
>>> round(Distortion.tsallis(2.0).g(0.3), 12), Distortion.tsallis(3.0).gini

(0.51, 0.25)


tvar()

Tail value at risk at level p: g(s) = min(s / (1 - p), 1).

Usage

Source

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

wang()

Wang transform: g(s) = Phi(Phi^-1(s) + lambda).

Usage

Source

wang(lam)
Parameters
lam: float
Market price of risk, >= 0.
Returns
Distortion

weighted_tvar()

A weighted average of TVaRs.

Usage

Source

weighted_tvar(ps, wts)
Parameters
ps: list of float

Strictly ascending levels in [0, 1].

wts: list of float
Non-negative weights summing to 1.
Returns
Distortion

weights()

Weights for n equally likely values sorted ascending.

Usage

Source

weights(n)
Parameters
n: int
Returns
list of float
Non-negative, summing to 1.