pub struct LogAffinePareto { /* private fields */ }Expand description
Log-affine local Pareto: above the threshold t the local Pareto alpha
is α(x) = α₀ (1 + γ ln(x/t)), so with L = ln(x/t)
P(X > x) = exp(−α₀ L − ½ α₀ γ L²), x ≥ t,and 1 below t. The tail thins out with size (lognormal-like) at a
rate set by two readable numbers: the alpha α₀ at the threshold and
δ = α₀ γ ln 2, the rise in alpha each time the amount doubles.
γ = 0 is the Pareto. Matches pLALocPareto(x, t, alpha_0, gamma) in
the R package LocalPareto.
In L the survival function is a Gaussian, so every layer moment
reduces to normal tail probabilities, evaluated through the Mills ratio
so that layers far in the tail keep full relative precision.
use prospicio_prob::{Distribution, LogAffinePareto, Severity};
// Alpha 1.5 at 1m, rising by 0.5 per doubling.
let d = LogAffinePareto::from_delta(1e6, 1.5, 0.5).unwrap();
assert!((d.local_alpha(2e6) - 2.0).abs() < 1e-14);
assert!(d.layer(4e6, 1e6) > 0.0 && d.mean().is_finite());Implementations§
Source§impl LogAffinePareto
impl LogAffinePareto
Sourcepub fn new(t: f64, alpha0: f64, gamma: f64) -> Result<Self>
pub fn new(t: f64, alpha0: f64, gamma: f64) -> Result<Self>
Threshold t > 0, alpha α₀ > 0 at the threshold and γ ≥ 0 (a
falling alpha would turn negative far out).
Sourcepub fn from_delta(t: f64, alpha0: f64, delta: f64) -> Result<Self>
pub fn from_delta(t: f64, alpha0: f64, delta: f64) -> Result<Self>
The same distribution from δ = α₀ γ ln 2 ≥ 0, the increase in
the local alpha when the amount doubles.
pub fn t(&self) -> f64
pub fn gamma(&self) -> f64
Sourcepub fn local_alpha(&self, x: f64) -> f64
pub fn local_alpha(&self, x: f64) -> f64
The local Pareto alpha −x S'(x) / S(x) at x ≥ t (0 below).
Trait Implementations§
Source§impl Clone for LogAffinePareto
impl Clone for LogAffinePareto
Source§fn clone(&self) -> LogAffinePareto
fn clone(&self) -> LogAffinePareto
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for LogAffinePareto
Source§impl Debug for LogAffinePareto
impl Debug for LogAffinePareto
Source§impl Distribution for LogAffinePareto
impl Distribution for LogAffinePareto
Source§fn quantile(&self, p: f64) -> Result<f64>
fn quantile(&self, p: f64) -> Result<f64>
Solves ½ α₀ γ L² + α₀ L + ln s = 0 for L ≥ 0 in the form
L = −2 ln s / (α₀ + √(α₀² − 2 α₀ γ ln s)), which has no
cancellation and covers γ = 0.
Source§fn survival(&self, x: f64) -> f64
fn survival(&self, x: f64) -> f64
P(X > x). Representations with a direct form override the
default 1 - cdf(x), which loses all precision far in the tail.Source§fn sample(&self, rng: &mut StreamRng, n: usize) -> Vec<f64>
fn sample(&self, rng: &mut StreamRng, n: usize) -> Vec<f64>
n draws from stream rng, by inverse transform unless the family
overrides it (crate::Gamma draws by Marsaglia and Tsang). Read moreSource§fn is_parallel_safe(&self) -> bool
fn is_parallel_safe(&self) -> bool
crate::Custom
whose callbacks must stay on the calling thread (an R function), so
the parallel simulations run single-threaded when they meet one.Source§impl From<LogAffinePareto> for Dist
impl From<LogAffinePareto> for Dist
Source§fn from(d: LogAffinePareto) -> Self
fn from(d: LogAffinePareto) -> Self
Source§impl PartialEq for LogAffinePareto
impl PartialEq for LogAffinePareto
Source§impl Severity for LogAffinePareto
impl Severity for LogAffinePareto
Source§fn layer_second_moment(&self, limit: f64, attachment: f64) -> f64
fn layer_second_moment(&self, limit: f64, attachment: f64) -> f64
2 ∫_a^b (x − a) S(x) dx with b = a + limit.
Source§fn stop_loss(&self, retention: f64) -> f64
fn stop_loss(&self, retention: f64) -> f64
E[max(X - retention, 0)].impl StructuralPartialEq for LogAffinePareto
Auto Trait Implementations§
impl Freeze for LogAffinePareto
impl RefUnwindSafe for LogAffinePareto
impl Send for LogAffinePareto
impl Sync for LogAffinePareto
impl Unpin for LogAffinePareto
impl UnsafeUnpin for LogAffinePareto
impl UnwindSafe for LogAffinePareto
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
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> ⓘ
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> ⓘ
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