Skip to main content

hill

Function hill 

Source
pub fn hill(draws: &[f64], ks: &[usize]) -> Result<Vec<f64>>
Expand description

Hill estimates of the tail index ξ (1/α for a Pareto tail) from the k largest draws, for each k in ks: ξ̂_k = (1/k) Σ_{i=1..k} ln X_(n-i+1) - ln X_(n-k).

A plot of ξ̂_k against k that settles over a range of k suggests a heavy (Pareto-type) tail with that index. Fails if a k is 0 or leaves no draw below the top k, or the k + 1 largest draws are not all positive.

use prospicio_prob::evt::hill;

// Exact Pareto quantiles with α = 2: ξ̂ is close to 1/2.
let n = 10_000;
let x: Vec<f64> = (1..=n).map(|i| (1.0 - (i as f64 - 0.5) / n as f64).powf(-0.5)).collect();
let xi = hill(&x, &[1000]).unwrap()[0];
assert!((xi - 0.5).abs() < 0.01);