Skip to main content

distributions.ChfDistribution

A law’s bucket masses on a grid, from its characteristic function: what

Usage

Source

distributions.ChfDistribution()

invert_chf returns.

Bucket k holds the law’s probability within half a step of x_min + k * step (the rounding discretization). The masses are as inverted, not renormalized; the statistics are those of the masses on the window.

Attributes

Name Description
edge_error The modelled worst relative error of a bucket at the heavy end of a
is_truncated Whether truncation_error is above 1e-6.
law_mean The law’s mean (nan for your own function).
law_variance The law’s variance (nan for your own function).
log2 The grid has 2 ** log2 buckets.
masses The bucket masses, as inverted.
outside_above The Chernoff bound on the law’s mass above the window, which wraps
outside_below The Chernoff bound on the law’s mass below the window, which wraps
step The bucket.
step_given Whether the bucket was given rather than sized from the law’s tails.
tilt (left, right): the e-folds of damping across the window on each
total_mass The sum of the masses.
truncation_error |phi(pi / step)| of the continuous part: the frequencies the
x_min The first grid point.
xs The grid points.

edge_error

The modelled worst relative error of a bucket at the heavy end of a

edge_error: float

law with one power tail; nan for any other law.


is_truncated

Whether truncation_error is above 1e-6.

is_truncated: bool


law_mean

The law’s mean (nan for your own function).

law_mean: float


law_variance

The law’s variance (nan for your own function).

law_variance: float


log2

The grid has 2 ** log2 buckets.

log2: int


masses

The bucket masses, as inverted.

masses: list[float]


outside_above

The Chernoff bound on the law’s mass above the window, which wraps

outside_above: float

onto its bottom; 0 on a grid whose left edge was given.


outside_below

The Chernoff bound on the law’s mass below the window, which wraps

outside_below: float

onto its top; 0 on a grid whose left edge was given.


step

The bucket.

step: float


step_given

Whether the bucket was given rather than sized from the law’s tails.

step_given: bool


tilt

(left, right): the e-folds of damping across the window on each

tilt: tuple[float, float]

side, (0, tau) for a right power tail tilted, (tau, 0) for a left one, (0, 0) untilted.


total_mass

The sum of the masses.

total_mass: float


truncation_error

|phi(pi / step)| of the continuous part: the frequencies the

truncation_error: float

inversion drops. Above 1e-6 the masses ring; lower the step.


x_min

The first grid point.

x_min: float


xs

The grid points.

xs: list[float]

Methods

Name Description
cdf() The sum of the masses at grid points at or below x.
mean() The mean of the masses on the window.
quantile() The first grid point whose cumulative mass reaches p.
std_dev() The standard deviation of the masses on the window.
to_grid() The masses as a Grid from 0, negative round-off set to 0 and the
tvar() The tail value at risk at p, as aggregate’s
variance() The variance of the masses on the window.

cdf()

The sum of the masses at grid points at or below x.

Usage

Source

cdf(x)
Parameters
x: float
Returns
float

mean()

The mean of the masses on the window.

Usage

Source

mean()

quantile()

The first grid point whose cumulative mass reaches p.

Usage

Source

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

std_dev()

The standard deviation of the masses on the window.

Usage

Source

std_dev()

to_grid()

The masses as a Grid from 0, negative round-off set to 0 and the

Usage

Source

to_grid()

sum rescaled to 1, for the compound and risk-measure functions.

Returns
Grid
Raises
ValueError
If the window starts below 0.

tvar()

The tail value at risk at p, as aggregate’s

Usage

Source

tvar(p)

AggregateCHF.tvar: over the buckets of positive mass, their masses as inverted (not renormalized); the largest such point at p = 1.

Parameters
p: float
In [0, 1].
Returns
float
Examples
>>> from prospicio.distributions import Normal, invert_chf
>>> d = invert_chf(Normal(0.0, 1.0), log2=12)
>>> round(d.tvar(0.99), 3)

2.665


variance()

The variance of the masses on the window.

Usage

Source

variance()