pub struct PotTail { /* private fields */ }Expand description
A peaks-over-threshold tail: draws above threshold modelled by a GPD.
P(X > x) = p_u · S_GPD(x - u) for x >= u, where p_u is the share
of draws above the threshold. VaR and TVaR at levels p >= 1 - p_u
come from the GPD, so they extend smoothly past the largest draw.
use prospicio_core::StreamRng;
use prospicio_prob::{Distribution, Lognormal, Sampled, evt::PotTail};
let d = Lognormal::new(0.0, 1.0).unwrap();
let s = Sampled::new(d.sample(&mut StreamRng::new(3, 0), 100_000)).unwrap();
let tail = PotTail::fit(&s, 0.95).unwrap();
// The 99.9% quantile of LN(0, 1) is 21.98.
let q = tail.var(0.999).unwrap();
assert!((q / 21.98 - 1.0).abs() < 0.05, "{q}");Implementations§
Source§impl PotTail
impl PotTail
Sourcepub fn fit(draws: &impl Empirical, level: f64) -> Result<Self>
pub fn fit(draws: &impl Empirical, level: f64) -> Result<Self>
Fits a GPD to the draws above the empirical level quantile of
draws (for example 0.95 for the top 5%).
Sourcepub fn new(threshold: f64, p_exceed: f64, gpd: Gpd) -> Result<Self>
pub fn new(threshold: f64, p_exceed: f64, gpd: Gpd) -> Result<Self>
A tail from known parts; gpd models the exceedances, so its
location must be 0.
pub fn threshold(&self) -> f64
pub fn gpd(&self) -> &Gpd
Trait Implementations§
impl StructuralPartialEq for PotTail
Auto Trait Implementations§
impl Freeze for PotTail
impl RefUnwindSafe for PotTail
impl Send for PotTail
impl Sync for PotTail
impl Unpin for PotTail
impl UnsafeUnpin for PotTail
impl UnwindSafe for PotTail
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more