## risk.statistics()


A results table's statistics in one call, under stated conventions.


Usage


``` python
risk.statistics(
    dist,
    percentiles,
    *,
    tvar_levels=None,
    sd_multiples=None,
    quantile="inverted_cdf",
    tvar="exact"
)
```


Every table has `"Mean"`, `"SD"` (population, dividing by [n](pricing.TrendFit.md#prospicio.pricing.TrendFit.n)), `"CoV"` (`sd / mean`; 0 when both are 0, NaN when only the mean is), `"Min"`, `"Max"` and `"Variance"`, then `"Percentile <q>"` for each percentile, `"TVaR <q>"` for each TVaR level and `"Mean + <k> SD"`, `"Mean - <k> SD"` for each multiple, with levels in percent as given, so the names are stable keys to join on.


## Parameters


`dist: Sampled, PredictiveDistribution or list of float`  
A predictive distribution gives one row per component.

`percentiles: list of float`  
In percent, in `[0, 100]`.

`tvar_levels: list of float = None`  
In percent; by default 99, 99.5, 99.6, 99.8, 99.9 and 99.99.

`sd_multiples: list of float = None`  
By default 1, 2 and 3.

`quantile: str = ``"inverted_cdf"`  
`"inverted_cdf"` (the default, [Sampled.var](distributions.Sampled.md#prospicio.distributions.Sampled.var)'s), `"linear"` (numpy's default, R `type = 7`) or `"kth_largest"` (the [k](models.TargetEncoding.md#prospicio.models.TargetEncoding.k)-th largest draw, `k = max(1, floor((1 - p) n))`).

`tvar: str = ``"exact"`  
`"exact"` (the default, [Sampled.tvar](distributions.Sampled.md#prospicio.distributions.Sampled.tvar)'s, mass `1/n` per draw), `"linear"` (the mean of the linear quantile function over `[p, 1]`) or `"whole_years"` (the mean of the [k](models.TargetEncoding.md#prospicio.models.TargetEncoding.k) largest draws).


## Returns


`dict`  
For a [Sampled](distributions.Sampled.md#prospicio.distributions.Sampled) or a list, `{name: value}`. For a [PredictiveDistribution](distributions.PredictiveDistribution.md#prospicio.distributions.PredictiveDistribution), columns: one list per dimension holding each component's key, then one list per statistic, ready for `pandas.DataFrame`.


## Raises


`ValueError`  
If a level is outside `[0, 100]` or a method name is unknown.


## Examples

``` python
>>> from prospicio.risk import statistics
>>> st = statistics([1.0, 2.0, 3.0, 4.0], [50], tvar_levels=[50],
...                 quantile="linear", tvar="linear")
>>> st["Percentile 50"], st["TVaR 50"]
```

(2.5, 3.25)
