pub struct SeverityDist(/* private fields */);Expand description
A Dist known to be a Severity: every variant but
Dist::Sampled.
This is what the bindings accept wherever a loss severity is required
(collective models, layers, copula marginals, mixture components). It
dispatches by match, like Dist, with no vtable.
use prospicio_prob::{Dist, Lognormal, Sampled, Severity, SeverityDist};
let ln = Lognormal::from_mean_cv(1000.0, 0.5).unwrap();
let s = SeverityDist::try_from(Dist::from(ln)).unwrap();
assert_eq!(s.lev(800.0), ln.lev(800.0));
let draws = Dist::from(Sampled::new(vec![1.0, 2.0]).unwrap());
assert!(SeverityDist::try_from(draws).is_err());Implementations§
Trait Implementations§
Source§impl Clone for SeverityDist
impl Clone for SeverityDist
Source§fn clone(&self) -> SeverityDist
fn clone(&self) -> SeverityDist
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SeverityDist
impl Debug for SeverityDist
Source§impl Distribution for SeverityDist
impl Distribution for SeverityDist
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 From<SeverityDist> for Dist
impl From<SeverityDist> for Dist
Source§fn from(s: SeverityDist) -> Self
fn from(s: SeverityDist) -> Self
Converts to this type from the input type.
Source§impl Severity for SeverityDist
impl Severity for SeverityDist
Source§fn stop_loss(&self, retention: f64) -> f64
fn stop_loss(&self, retention: f64) -> f64
Expected excess over a retention,
E[max(X - retention, 0)].Source§fn layer(&self, limit: f64, attachment: f64) -> f64
fn layer(&self, limit: f64, attachment: f64) -> f64
Expected loss to the layer
limit xs attachment,
E[min(max(X - attachment, 0), limit)].Auto Trait Implementations§
impl !RefUnwindSafe for SeverityDist
impl !UnwindSafe for SeverityDist
impl Freeze for SeverityDist
impl Send for SeverityDist
impl Sync for SeverityDist
impl Unpin for SeverityDist
impl UnsafeUnpin for SeverityDist
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