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 gen = Gaussian::standard();
let sample: Vec<f64> = gen.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| {
gen.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
source§impl PartialEq for Empirical
impl PartialEq for Empirical
source§impl PartialOrd for Empirical
impl PartialOrd for Empirical
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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.