pub struct Sampled { /* private fields */ }Expand description
A distribution represented by n equally weighted draws.
Every Distribution method describes the empirical distribution of
the draws: variance divides by n, not n - 1, and quantile is
the inverse of the empirical distribution function (R type = 1).
sample resamples the draws with replacement.
§Example
use prospicio_core::StreamRng;
use prospicio_prob::{Distribution, Empirical, Lognormal, Sampled};
let d = Lognormal::from_mean_cv(1000.0, 0.5).unwrap();
let s = Sampled::new(d.sample(&mut StreamRng::new(42, 0), 10_000)).unwrap();
assert!((s.mean() - 1000.0).abs() < 20.0);
assert!(s.tvar(0.99).unwrap() > s.var(0.99).unwrap());Implementations§
Trait Implementations§
Source§impl Distribution for Sampled
impl Distribution for Sampled
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 Empirical for Sampled
impl Empirical for Sampled
Source§fn draws(&self) -> &[f64]
fn draws(&self) -> &[f64]
The draws, in the order they were simulated. Draw
i came from
simulation i, so two distributions from the same simulations can
be paired draw by draw.Source§fn distortion(&self, d: &Distortion) -> f64
fn distortion(&self, d: &Distortion) -> f64
Distortion risk measure of the draws; see
Distortion::apply_sorted. Read moreimpl StructuralPartialEq for Sampled
Auto Trait Implementations§
impl Freeze for Sampled
impl RefUnwindSafe for Sampled
impl Send for Sampled
impl Sync for Sampled
impl Unpin for Sampled
impl UnsafeUnpin for Sampled
impl UnwindSafe for Sampled
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