Distribution on finitely many values, of either sign
discrete_distribution.RdProbabilities probs on values, any sign and any spacing: a row of a
P&L (premium less loss less expenses) or any other signed outcome, as the
Python package aggregate's GridDistribution on an irregular support.
Values may repeat and come in any order: equal values (to 1e-12) are
merged and zero probabilities dropped. The probabilities must sum to 1
within 1e-5 (aggregate 2.1.0's rule for dsev); normalize = TRUE
rescales weights or counts of any positive total.
Usage
discrete_distribution(values, probs, normalize = FALSE, ptr = NULL)
discrete_skewness(dist)
quantile_upper(dist, p)
return_periods(dist, periods = NULL)Value
discrete_distribution() a discrete_distribution, which
inherits from distribution; return_periods() a data frame with p,
period, var, tvar, excess (VaR less the mean) and var_to_mean.
Details
Supports mean(), variance(), cdf(), survival(), pmf(),
quantile() (the lower quantile), VaR() and TVaR(), following
aggregate exactly. TVaR() is the upper tail even when the values are a
payoff, whose adverse tail is the low one. discrete_skewness() is NA
when the variance is 0; quantile_upper() is the smallest value with
F > p (NA at p = 1); return_periods() is aggregate's
return-period table, each period read from both tails (a payoff off the
low rows, a loss off the high ones).
Examples
# A margin: 9 less the loss of two claims of 1, 2 or 4.
m <- discrete_distribution(c(7, 6, 5, 4, 3, 1), c(0.25, 0.3, 0.09, 0.2, 0.12, 0.04))
mean(m)
#> [1] 5.2
quantile(m, 0.01) # the 1-in-100 bad year
#> [1] 1
TVaR(m, 0.01)
#> [1] 5.242424
head(return_periods(m), 3)
#> p period var tvar excess var_to_mean
#> 1 0.001 1000 1 5.204204 -4.2 0.1923077
#> 2 0.002 500 1 5.208417 -4.2 0.1923077
#> 3 0.004 250 1 5.216867 -4.2 0.1923077