risk.statistics()
A results table’s statistics in one call, under stated conventions.
Usage
risk.statistics(
dist,
percentiles,
*,
tvar_levels=None,
sd_multiples=None,
quantile="inverted_cdf",
tvar="exact"
)Every table has "Mean", "SD" (population, dividing by 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’s),"linear"(numpy’s default, Rtype = 7) or"kth_largest"(the k-th largest draw,k = max(1, floor((1 - p) n))). tvar: str = "exact"-
"exact"(the default, Sampled.tvar’s, mass1/nper draw),"linear"(the mean of the linear quantile function over[p, 1]) or"whole_years"(the mean of the k largest draws).
Returns
dict-
For a Sampled or a list,
{name: value}. For a PredictiveDistribution, columns: one list per dimension holding each component’s key, then one list per statistic, ready forpandas.DataFrame.
Raises
ValueError-
If a level is outside
[0, 100]or a method name is unknown.
Examples
>>> 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)