pub struct Lognormal { /* private fields */ }Expand description
Lognormal distribution: ln X ~ Normal(meanlog, sdlog^2).
Parameterized as in SciPy (s = sdlog, scale = exp(meanlog)), R
(meanlog, sdlog) and actuar.
§Example
use prospicio_prob::{Distribution, Lognormal};
let d = Lognormal::from_mean_cv(1000.0, 0.5).unwrap();
assert!((d.mean() - 1000.0).abs() < 1e-9);
assert!((d.std_dev() - 500.0).abs() < 1e-9);Implementations§
Source§impl Lognormal
impl Lognormal
Trait Implementations§
impl Copy for Lognormal
Source§impl Distribution for Lognormal
impl Distribution for Lognormal
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
Whether the distribution may be evaluated on several threads at
once. True for every native family; false for a
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 Severity for Lognormal
impl Severity for Lognormal
Source§fn lev(&self, limit: f64) -> f64
fn lev(&self, limit: f64) -> f64
E[min(X, d)] = e^(mu + s^2/2) Phi((ln d - mu - s^2) / s) + d (1 - Phi((ln d - mu) / s)).
Source§fn stop_loss(&self, retention: f64) -> f64
fn stop_loss(&self, retention: f64) -> f64
E[(X - d)+] = e^(mu + s^2/2) Phi((mu + s^2 - ln d) / s) - d Phi((mu - ln d) / s),
with both terms small in the tail, so it keeps full relative
precision where mean() - lev(d) would cancel.
Source§fn layer_second_moment(&self, limit: f64, attachment: f64) -> f64
fn layer_second_moment(&self, limit: f64, attachment: f64) -> f64
With b = a + limit and Y the layer loss,
E[Y^2] = E[(X - a)^2; a < X <= b] + limit^2 P(X > b), from the
partial moments E[X^k; a < X <= b] = e^(k mu + k^2 s^2 / 2) (Phi(z_b - k s) - Phi(z_a - k s)). Differences of Phi are taken in
the upper tail so they keep their precision for high layers.
impl StructuralPartialEq for Lognormal
Auto Trait Implementations§
impl Freeze for Lognormal
impl RefUnwindSafe for Lognormal
impl Send for Lognormal
impl Sync for Lognormal
impl Unpin for Lognormal
impl UnsafeUnpin for Lognormal
impl UnwindSafe for Lognormal
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