pub fn mean_excess(draws: &[f64], thresholds: &[f64]) -> Vec<(f64, f64, usize)>Expand description
The empirical mean-excess function e(u) = E[X - u | X > u] at each
threshold, with the number of draws above it: (u, e(u), n_u), e(u)
NaN where no draw exceeds u.
Above a threshold where a GPD fits, e(u) is linear in u with slope
ξ / (1 - ξ), so the plot of e(u) against u is the classic aid to
choosing a threshold: pick u where it turns straight.
use prospicio_prob::evt::mean_excess;
let e = mean_excess(&[1.0, 2.0, 3.0, 4.0], &[2.0, 4.0]);
assert_eq!(e[0], (2.0, 1.5, 2)); // (3 - 2 + 4 - 2) / 2
assert_eq!(e[1].2, 0);