pub struct Shifted<D> { /* private fields */ }Expand description
A wrapper for distributions that adds a shift parameter
§Example
use rv::prelude::*;
use rv::dist::{Shifted, Gaussian};
let shifted = Shifted::new(Gaussian::standard(), 5.0).expect("Valid Input");
assert_eq!(shifted.mean(), Some(5.0));
assert_eq!(shifted.variance(), Some(1.0));Implementations§
Source§impl<D> Shifted<D>
impl<D> Shifted<D>
Sourcepub fn new(parent: D, shift: f64) -> Result<Self, ShiftedError>
pub fn new(parent: D, shift: f64) -> Result<Self, ShiftedError>
Create a new shifted distribution with a given parent distribution and a offset parameter.
§Example
use rv::prelude::*;
let _ok = Shifted::new(Gaussian::standard(), 5.0).unwrap();
let _err = Shifted::new(Gaussian::standard(), f64::INFINITY);Sourcepub fn new_unchecked(parent: D, shift: f64) -> Self
pub fn new_unchecked(parent: D, shift: f64) -> Self
Create a new Shifted distribution without checking the shift parameter is finite.
Trait Implementations§
Source§impl<Pr, Fx> ConjugatePrior<f64, Shifted<Fx>> for ShiftedPrior<Pr, Fx>where
Pr: ConjugatePrior<f64, Fx, Posterior = Pr>,
Fx: HasSuffStat<f64> + Shiftable + HasDensity<f64>,
Shifted<Fx>: HasSuffStat<f64, Stat = ShiftedSuffStat<Fx::Stat>>,
impl<Pr, Fx> ConjugatePrior<f64, Shifted<Fx>> for ShiftedPrior<Pr, Fx>where
Pr: ConjugatePrior<f64, Fx, Posterior = Pr>,
Fx: HasSuffStat<f64> + Shiftable + HasDensity<f64>,
Shifted<Fx>: HasSuffStat<f64, Stat = ShiftedSuffStat<Fx::Stat>>,
Source§type Posterior = ShiftedPrior<Pr, Fx>
type Posterior = ShiftedPrior<Pr, Fx>
Type of the posterior distribution
Source§type MCache = <Pr as ConjugatePrior<f64, Fx>>::MCache
type MCache = <Pr as ConjugatePrior<f64, Fx>>::MCache
Type of the cache for the marginal likelihood
Source§type PpCache = <Pr as ConjugatePrior<f64, Fx>>::PpCache
type PpCache = <Pr as ConjugatePrior<f64, Fx>>::PpCache
Type of the cache for the posterior predictive
Source§fn empty_stat(&self) -> ShiftedSuffStat<Fx::Stat>
fn empty_stat(&self) -> ShiftedSuffStat<Fx::Stat>
Generate and empty sufficient statistic
Source§fn posterior_from_suffstat(
&self,
stat: &ShiftedSuffStat<Fx::Stat>,
) -> Self::Posterior
fn posterior_from_suffstat( &self, stat: &ShiftedSuffStat<Fx::Stat>, ) -> Self::Posterior
Computes the posterior distribution from the data
fn posterior(&self, x: &DataOrSuffStat<'_, f64, Shifted<Fx>>) -> Self::Posterior
Source§fn ln_m_cache(&self) -> Self::MCache
fn ln_m_cache(&self) -> Self::MCache
Compute the cache for the log marginal likelihood.
Source§fn ln_m_with_cache(
&self,
cache: &Self::MCache,
x: &DataOrSuffStat<'_, f64, Shifted<Fx>>,
) -> f64
fn ln_m_with_cache( &self, cache: &Self::MCache, x: &DataOrSuffStat<'_, f64, Shifted<Fx>>, ) -> f64
Log marginal likelihood with supplied cache.
Source§fn ln_pp_cache(&self, x: &DataOrSuffStat<'_, f64, Shifted<Fx>>) -> Self::PpCache
fn ln_pp_cache(&self, x: &DataOrSuffStat<'_, f64, Shifted<Fx>>) -> Self::PpCache
Compute the cache for the Log posterior predictive of y given x. Read more
Source§fn ln_pp_with_cache(&self, cache: &Self::PpCache, y: &f64) -> f64
fn ln_pp_with_cache(&self, cache: &Self::PpCache, y: &f64) -> f64
Log posterior predictive of y given x with supplied ln(norm)
Source§fn ln_m(&self, x: &DataOrSuffStat<'_, X, Fx>) -> f64
fn ln_m(&self, x: &DataOrSuffStat<'_, X, Fx>) -> f64
The log marginal likelihood
Source§fn ln_pp(&self, y: &X, x: &DataOrSuffStat<'_, X, Fx>) -> f64
fn ln_pp(&self, y: &X, x: &DataOrSuffStat<'_, X, Fx>) -> f64
Log posterior predictive of y given x
Source§fn m(&self, x: &DataOrSuffStat<'_, X, Fx>) -> f64
fn m(&self, x: &DataOrSuffStat<'_, X, Fx>) -> f64
Marginal likelihood of x
fn pp_with_cache(&self, cache: &Self::PpCache, y: &X) -> f64
Source§impl<D> ContinuousDistr<f64> for Shifted<D>where
D: ContinuousDistr<f64>,
impl<D> ContinuousDistr<f64> for Shifted<D>where
D: ContinuousDistr<f64>,
Source§impl<'de, D> Deserialize<'de> for Shifted<D>where
D: Deserialize<'de>,
impl<'de, D> Deserialize<'de> for Shifted<D>where
D: Deserialize<'de>,
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<D> HasDensity<f64> for Shifted<D>where
D: HasDensity<f64>,
impl<D> HasDensity<f64> for Shifted<D>where
D: HasDensity<f64>,
Source§impl<D> HasSuffStat<f64> for Shifted<D>where
D: HasSuffStat<f64>,
impl<D> HasSuffStat<f64> for Shifted<D>where
D: HasSuffStat<f64>,
Source§impl<D> InverseCdf<f64> for Shifted<D>where
D: InverseCdf<f64>,
impl<D> InverseCdf<f64> for Shifted<D>where
D: InverseCdf<f64>,
Source§impl<D> Parameterized for Shifted<D>where
D: Parameterized,
impl<D> Parameterized for Shifted<D>where
D: Parameterized,
type Parameters = ShiftedParameters<D>
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<Pr, Fx> Sampleable<Shifted<Fx>> for ShiftedPrior<Pr, Fx>where
Pr: Sampleable<Fx>,
Fx: Shiftable,
impl<Pr, Fx> Sampleable<Shifted<Fx>> for ShiftedPrior<Pr, Fx>where
Pr: Sampleable<Fx>,
Fx: Shiftable,
Source§impl<D> Sampleable<f64> for Shifted<D>where
D: Sampleable<f64>,
impl<D> Sampleable<f64> for Shifted<D>where
D: Sampleable<f64>,
impl<D> StructuralPartialEq for Shifted<D>
Auto Trait Implementations§
impl<D> Freeze for Shifted<D>where
D: Freeze,
impl<D> RefUnwindSafe for Shifted<D>where
D: RefUnwindSafe,
impl<D> Send for Shifted<D>where
D: Send,
impl<D> Sync for Shifted<D>where
D: Sync,
impl<D> Unpin for Shifted<D>where
D: Unpin,
impl<D> UnwindSafe for Shifted<D>where
D: UnwindSafe,
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.