Enum rv::data::DataOrSuffStat
source · pub enum DataOrSuffStat<'a, X, Fx>where
X: 'a,
Fx: 'a + HasSuffStat<X>,{
Data(&'a [X]),
SuffStat(&'a Fx::Stat),
None,
}
Expand description
Holds either a sufficient statistic of a vector of data.
Variants§
Implementations§
source§impl<'a, X, Fx> DataOrSuffStat<'a, X, Fx>where
X: 'a,
Fx: 'a + HasSuffStat<X>,
impl<'a, X, Fx> DataOrSuffStat<'a, X, Fx>where X: 'a, Fx: 'a + HasSuffStat<X>,
sourcepub fn is_data(&self) -> bool
pub fn is_data(&self) -> bool
Determine whether the object contains data
Example
use rv::dist::Gaussian;
use rv::data::GaussianSuffStat;
let xs = vec![1.0_f64];
let data: DataOrSuffStat<f64, Gaussian> = DataOrSuffStat::Data(&xs);
assert!(data.is_data());
let gauss_stats = GaussianSuffStat::new();
let suffstat: DataOrSuffStat<f64, Gaussian> = DataOrSuffStat::SuffStat(&gauss_stats);
assert!(!suffstat.is_data());
sourcepub fn is_suffstat(&self) -> bool
pub fn is_suffstat(&self) -> bool
Determine whether the object contains sufficient statistics
Example
use rv::dist::Gaussian;
use rv::data::GaussianSuffStat;
let xs = vec![1.0_f64];
let data: DataOrSuffStat<f64, Gaussian> = DataOrSuffStat::Data(&xs);
assert!(!data.is_suffstat());
let gauss_stats = GaussianSuffStat::new();
let suffstat: DataOrSuffStat<f64, Gaussian> = DataOrSuffStat::SuffStat(&gauss_stats);
assert!(suffstat.is_suffstat());
sourcepub fn is_none(&self) -> bool
pub fn is_none(&self) -> bool
Determine whether the object is empty
Example
use rv::dist::Gaussian;
use rv::data::GaussianSuffStat;
let xs = vec![1.0_f64];
let data: DataOrSuffStat<f64, Gaussian> = DataOrSuffStat::Data(&xs);
assert!(!data.is_none());
let gauss_stats = GaussianSuffStat::new();
let suffstat: DataOrSuffStat<f64, Gaussian> = DataOrSuffStat::SuffStat(&gauss_stats);
assert!(!suffstat.is_none());
let none: DataOrSuffStat<f64, Gaussian> = DataOrSuffStat::None;
assert!(none.is_none());
Trait Implementations§
source§impl<'a, X, Fx> Clone for DataOrSuffStat<'a, X, Fx>where
X: 'a + Clone,
Fx: 'a + HasSuffStat<X> + Clone,
Fx::Stat: Clone,
impl<'a, X, Fx> Clone for DataOrSuffStat<'a, X, Fx>where X: 'a + Clone, Fx: 'a + HasSuffStat<X> + Clone, Fx::Stat: Clone,
source§fn clone(&self) -> DataOrSuffStat<'a, X, Fx>
fn clone(&self) -> DataOrSuffStat<'a, X, Fx>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<'a, X, Fx> Debug for DataOrSuffStat<'a, X, Fx>where
X: 'a + Debug,
Fx: 'a + HasSuffStat<X> + Debug,
Fx::Stat: Debug,
impl<'a, X, Fx> Debug for DataOrSuffStat<'a, X, Fx>where X: 'a + Debug, Fx: 'a + HasSuffStat<X> + Debug, Fx::Stat: Debug,
source§impl<'a, X> From<&'a [X]> for DataOrSuffStat<'a, X, Categorical>where
X: CategoricalDatum,
impl<'a, X> From<&'a [X]> for DataOrSuffStat<'a, X, Categorical>where X: CategoricalDatum,
source§impl<'a> From<&'a [f32]> for DataOrSuffStat<'a, f32, InvGaussian>
impl<'a> From<&'a [f32]> for DataOrSuffStat<'a, f32, InvGaussian>
source§impl<'a> From<&'a [f64]> for DataOrSuffStat<'a, f64, InvGaussian>
impl<'a> From<&'a [f64]> for DataOrSuffStat<'a, f64, InvGaussian>
source§impl<'a, X> From<&'a BernoulliSuffStat> for DataOrSuffStat<'a, X, Bernoulli>where
X: Booleable,
impl<'a, X> From<&'a BernoulliSuffStat> for DataOrSuffStat<'a, X, Bernoulli>where X: Booleable,
source§fn from(stat: &'a BernoulliSuffStat) -> Self
fn from(stat: &'a BernoulliSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a BetaSuffStat> for DataOrSuffStat<'a, f32, Beta>
impl<'a> From<&'a BetaSuffStat> for DataOrSuffStat<'a, f32, Beta>
source§fn from(stat: &'a BetaSuffStat) -> Self
fn from(stat: &'a BetaSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a BetaSuffStat> for DataOrSuffStat<'a, f64, Beta>
impl<'a> From<&'a BetaSuffStat> for DataOrSuffStat<'a, f64, Beta>
source§fn from(stat: &'a BetaSuffStat) -> Self
fn from(stat: &'a BetaSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a, X> From<&'a CategoricalSuffStat> for DataOrSuffStat<'a, X, Categorical>where
X: CategoricalDatum,
impl<'a, X> From<&'a CategoricalSuffStat> for DataOrSuffStat<'a, X, Categorical>where X: CategoricalDatum,
source§fn from(stat: &'a CategoricalSuffStat) -> Self
fn from(stat: &'a CategoricalSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a GaussianSuffStat> for DataOrSuffStat<'a, f32, Gaussian>
impl<'a> From<&'a GaussianSuffStat> for DataOrSuffStat<'a, f32, Gaussian>
source§fn from(stat: &'a GaussianSuffStat) -> Self
fn from(stat: &'a GaussianSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a GaussianSuffStat> for DataOrSuffStat<'a, f64, Gaussian>
impl<'a> From<&'a GaussianSuffStat> for DataOrSuffStat<'a, f64, Gaussian>
source§fn from(stat: &'a GaussianSuffStat) -> Self
fn from(stat: &'a GaussianSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a InvGammaSuffStat> for DataOrSuffStat<'a, f32, InvGamma>
impl<'a> From<&'a InvGammaSuffStat> for DataOrSuffStat<'a, f32, InvGamma>
source§fn from(stat: &'a InvGammaSuffStat) -> Self
fn from(stat: &'a InvGammaSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a InvGammaSuffStat> for DataOrSuffStat<'a, f64, InvGamma>
impl<'a> From<&'a InvGammaSuffStat> for DataOrSuffStat<'a, f64, InvGamma>
source§fn from(stat: &'a InvGammaSuffStat) -> Self
fn from(stat: &'a InvGammaSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a InvGaussianSuffStat> for DataOrSuffStat<'a, f32, InvGaussian>
impl<'a> From<&'a InvGaussianSuffStat> for DataOrSuffStat<'a, f32, InvGaussian>
source§fn from(stat: &'a InvGaussianSuffStat) -> Self
fn from(stat: &'a InvGaussianSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a InvGaussianSuffStat> for DataOrSuffStat<'a, f64, InvGaussian>
impl<'a> From<&'a InvGaussianSuffStat> for DataOrSuffStat<'a, f64, InvGaussian>
source§fn from(stat: &'a InvGaussianSuffStat) -> Self
fn from(stat: &'a InvGaussianSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a PoissonSuffStat> for DataOrSuffStat<'a, u16, Poisson>
impl<'a> From<&'a PoissonSuffStat> for DataOrSuffStat<'a, u16, Poisson>
source§fn from(stat: &'a PoissonSuffStat) -> Self
fn from(stat: &'a PoissonSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a PoissonSuffStat> for DataOrSuffStat<'a, u32, Poisson>
impl<'a> From<&'a PoissonSuffStat> for DataOrSuffStat<'a, u32, Poisson>
source§fn from(stat: &'a PoissonSuffStat) -> Self
fn from(stat: &'a PoissonSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a PoissonSuffStat> for DataOrSuffStat<'a, u8, Poisson>
impl<'a> From<&'a PoissonSuffStat> for DataOrSuffStat<'a, u8, Poisson>
source§fn from(stat: &'a PoissonSuffStat) -> Self
fn from(stat: &'a PoissonSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a> From<&'a PoissonSuffStat> for DataOrSuffStat<'a, usize, Poisson>
impl<'a> From<&'a PoissonSuffStat> for DataOrSuffStat<'a, usize, Poisson>
source§fn from(stat: &'a PoissonSuffStat) -> Self
fn from(stat: &'a PoissonSuffStat) -> Self
Converts to this type from the input type.
source§impl<'a, X> From<&'a Vec<X, Global>> for DataOrSuffStat<'a, X, Categorical>where
X: CategoricalDatum,
impl<'a, X> From<&'a Vec<X, Global>> for DataOrSuffStat<'a, X, Categorical>where X: CategoricalDatum,
source§impl<'a> From<&'a Vec<f32, Global>> for DataOrSuffStat<'a, f32, InvGaussian>
impl<'a> From<&'a Vec<f32, Global>> for DataOrSuffStat<'a, f32, InvGaussian>
source§impl<'a> From<&'a Vec<f64, Global>> for DataOrSuffStat<'a, f64, InvGaussian>
impl<'a> From<&'a Vec<f64, Global>> for DataOrSuffStat<'a, f64, InvGaussian>
source§impl<'a, X, Fx> PartialEq<DataOrSuffStat<'a, X, Fx>> for DataOrSuffStat<'a, X, Fx>where
X: 'a + PartialEq,
Fx: 'a + HasSuffStat<X> + PartialEq,
Fx::Stat: PartialEq,
impl<'a, X, Fx> PartialEq<DataOrSuffStat<'a, X, Fx>> for DataOrSuffStat<'a, X, Fx>where X: 'a + PartialEq, Fx: 'a + HasSuffStat<X> + PartialEq, Fx::Stat: PartialEq,
source§fn eq(&self, other: &DataOrSuffStat<'a, X, Fx>) -> bool
fn eq(&self, other: &DataOrSuffStat<'a, X, Fx>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<'a, X, Fx> StructuralPartialEq for DataOrSuffStat<'a, X, Fx>where X: 'a, Fx: 'a + HasSuffStat<X>,
Auto Trait Implementations§
impl<'a, X, Fx> RefUnwindSafe for DataOrSuffStat<'a, X, Fx>where X: RefUnwindSafe, <Fx as HasSuffStat<X>>::Stat: RefUnwindSafe,
impl<'a, X, Fx> Send for DataOrSuffStat<'a, X, Fx>where X: Sync, <Fx as HasSuffStat<X>>::Stat: Sync,
impl<'a, X, Fx> Sync for DataOrSuffStat<'a, X, Fx>where X: Sync, <Fx as HasSuffStat<X>>::Stat: Sync,
impl<'a, X, Fx> Unpin for DataOrSuffStat<'a, X, Fx>
impl<'a, X, Fx> UnwindSafe for DataOrSuffStat<'a, X, Fx>where X: RefUnwindSafe, <Fx as HasSuffStat<X>>::Stat: RefUnwindSafe,
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§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 more§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).§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.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.