pub fn var_sorted(sorted: &[f64], p: f64) -> Result<f64>Expand description
Value at risk: the smallest draw x with P(X <= x) >= p, the inverse
of the empirical distribution function (numpy.quantile(..., method="inverted_cdf"), R quantile(..., type = 1)).
p = 0 gives the smallest draw. sorted must be non-empty and sorted
ascending; this is checked only in debug builds.
use prospicio_prob::risk::var_sorted;
let x = [1.0, 2.0, 3.0, 4.0];
assert_eq!(var_sorted(&x, 0.5), Ok(2.0));
assert_eq!(var_sorted(&x, 0.51), Ok(3.0));