## distributions.ChfDistribution


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


Usage

``` python
distributions.ChfDistribution()
```


[invert_chf](distributions.invert_chf.md#prospicio.distributions.invert_chf) returns.

Bucket [k](models.TargetEncoding.md#prospicio.models.TargetEncoding.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](#edge_error) | The modelled worst relative error of a bucket at the heavy end of a |
| [is_truncated](#is_truncated) | Whether [truncation_error](distributions.ChfDistribution.md#prospicio.distributions.ChfDistribution.truncation_error) is above 1e-6. |
| [law_mean](#law_mean) | The law's mean (`nan` for your own function). |
| [law_variance](#law_variance) | The law's variance (`nan` for your own function). |
| [log2](#log2) | The grid has `2 ** log2` buckets. |
| [masses](#masses) | The bucket masses, as inverted. |
| [outside_above](#outside_above) | The Chernoff bound on the law's mass above the window, which wraps |
| [outside_below](#outside_below) | The Chernoff bound on the law's mass below the window, which wraps |
| [step](#step) | The bucket. |
| [step_given](#step_given) | Whether the bucket was given rather than sized from the law's tails. |
| [tilt](#tilt) | `(left, right)`: the e-folds of damping across the window on each |
| [total_mass](#total_mass) | The sum of the masses. |
| [truncation_error](#truncation_error) | `|phi(pi / step)|` of the continuous part: the frequencies the |
| [x_min](#x_min) | The first grid point. |
| [xs](#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](distributions.ChfDistribution.md#prospicio.distributions.ChfDistribution.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()](#cdf) | The sum of the masses at grid points at or below [x](distributions.Ogive.md#prospicio.distributions.Ogive.x). |
| [mean()](#mean) | The mean of the masses on the window. |
| [quantile()](#quantile) | The first grid point whose cumulative mass reaches [p](models.Elpd.md#prospicio.models.Elpd.p). |
| [std_dev()](#std_dev) | The standard deviation of the masses on the window. |
| [to_grid()](#to_grid) | The masses as a [Grid](distributions.Grid.md#prospicio.distributions.Grid) from 0, negative round-off set to 0 and the |
| [tvar()](#tvar) | The tail value at risk at [p](models.Elpd.md#prospicio.models.Elpd.p), as [aggregate](aggregate.Clash.md#prospicio.aggregate.Clash.aggregate)'s |
| [variance()](#variance) | The variance of the masses on the window. |

------------------------------------------------------------------------


#### cdf()


The sum of the masses at grid points at or below [x](distributions.Ogive.md#prospicio.distributions.Ogive.x).


Usage

``` python
cdf(x)
```


##### Parameters


`x: float`  


##### Returns


`float`  


------------------------------------------------------------------------


#### mean()


The mean of the masses on the window.


Usage

``` python
mean()
```


------------------------------------------------------------------------


#### quantile()


The first grid point whose cumulative mass reaches [p](models.Elpd.md#prospicio.models.Elpd.p).


Usage

``` python
quantile(p)
```


##### Parameters


`p: float`  
In `[0, 1]`.


##### Returns


`float`  


------------------------------------------------------------------------


#### std_dev()


The standard deviation of the masses on the window.


Usage

``` python
std_dev()
```


------------------------------------------------------------------------


#### to_grid()


The masses as a [Grid](distributions.Grid.md#prospicio.distributions.Grid) from 0, negative round-off set to 0 and the


Usage

``` python
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](models.Elpd.md#prospicio.models.Elpd.p), as [aggregate](aggregate.Clash.md#prospicio.aggregate.Clash.aggregate)'s


Usage

``` python
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

``` python
>>> 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

``` python
variance()
```
