pub struct Empirical { /* private fields */ }Expand description
An empirical distribution derived from samples.
WARNING: The ln_f and f methods are poor approximations.
They both are likely be have unbound errors.
use rv::dist::{Gaussian, Empirical};
use rv::prelude::*;
use rv::misc::linspace;
use rand_xoshiro::Xoshiro256Plus;
use rand::SeedableRng;
let mut rng = Xoshiro256Plus::seed_from_u64(0xABCD);
let dist = Gaussian::standard();
let sample: Vec<f64> = dist.sample(1000, &mut rng);
let emp_dist = Empirical::new(sample);
let ln_f_err: Vec<f64> = linspace(emp_dist.range().0, emp_dist.range().1, 1000)
.iter()
.map(|x| {
dist.ln_f(x) - emp_dist.ln_f(x)
}).collect();Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Empirical
impl<'de> Deserialize<'de> for Empirical
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl HasDensity<f64> for Empirical
impl HasDensity<f64> for Empirical
Source§impl Parameterized for Empirical
impl Parameterized for Empirical
type Parameters = EmpiricalParameters
fn emit_params(&self) -> Self::Parameters
fn from_params(params: Self::Parameters) -> Self
fn map_params(&self, f: impl Fn(Self::Parameters) -> Self::Parameters) -> Self
Source§impl PartialOrd for Empirical
impl PartialOrd for Empirical
Source§impl Sampleable<f64> for Empirical
impl Sampleable<f64> for Empirical
impl StructuralPartialEq for Empirical
Auto Trait Implementations§
impl Freeze for Empirical
impl RefUnwindSafe for Empirical
impl Send for Empirical
impl Sync for Empirical
impl Unpin for Empirical
impl UnwindSafe for Empirical
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
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.