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§

§

Data(&'a [X])

A Vec of raw data

§

SuffStat(&'a Fx::Stat)

A sufficient statistic

§

None

No data

Implementations§

source§

impl<'a, X, Fx> DataOrSuffStat<'a, X, Fx>
where X: 'a, Fx: 'a + HasSuffStat<X>,

source

pub fn n(&self) -> usize

Get the number of observations

source

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());
source

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());
source

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,

source§

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)

Performs copy-assignment from source. Read more
source§

impl<'a, X, Fx> Debug for DataOrSuffStat<'a, X, Fx>
where X: 'a + Debug, Fx: 'a + HasSuffStat<X> + Debug, Fx::Stat: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, X> From<&'a [X]> for DataOrSuffStat<'a, X, Bernoulli>
where X: Booleable,

source§

fn from(xs: &'a [X]) -> Self

Converts to this type from the input type.
source§

impl<'a, X> From<&'a [X]> for DataOrSuffStat<'a, X, Categorical>

source§

fn from(xs: &'a [X]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [f32]> for DataOrSuffStat<'a, f32, Beta>

source§

fn from(xs: &'a [f32]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [f32]> for DataOrSuffStat<'a, f32, Gaussian>

source§

fn from(xs: &'a [f32]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [f32]> for DataOrSuffStat<'a, f32, InvGamma>

source§

fn from(xs: &'a [f32]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [f32]> for DataOrSuffStat<'a, f32, InvGaussian>

source§

fn from(xs: &'a [f32]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [f32]> for DataOrSuffStat<'a, f32, UnitPowerLaw>

source§

fn from(xs: &'a [f32]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [f64]> for DataOrSuffStat<'a, f64, Beta>

source§

fn from(xs: &'a [f64]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [f64]> for DataOrSuffStat<'a, f64, Gaussian>

source§

fn from(xs: &'a [f64]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [f64]> for DataOrSuffStat<'a, f64, InvGamma>

source§

fn from(xs: &'a [f64]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [f64]> for DataOrSuffStat<'a, f64, InvGaussian>

source§

fn from(xs: &'a [f64]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [f64]> for DataOrSuffStat<'a, f64, UnitPowerLaw>

source§

fn from(xs: &'a [f64]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [u16]> for DataOrSuffStat<'a, u16, Poisson>

source§

fn from(xs: &'a [u16]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [u32]> for DataOrSuffStat<'a, u32, Poisson>

source§

fn from(xs: &'a [u32]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [u8]> for DataOrSuffStat<'a, u8, Poisson>

source§

fn from(xs: &'a [u8]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [usize]> for DataOrSuffStat<'a, usize, Poisson>

source§

fn from(xs: &'a [usize]) -> Self

Converts to this type from the input type.
source§

impl<'a, X> From<&'a BernoulliSuffStat> for DataOrSuffStat<'a, X, Bernoulli>
where X: Booleable,

source§

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>

source§

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>

source§

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>

source§

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>

source§

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>

source§

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>

source§

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>

source§

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>

source§

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>

source§

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>

source§

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>

source§

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>

source§

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>

source§

fn from(stat: &'a PoissonSuffStat) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a UnitPowerLawSuffStat> for DataOrSuffStat<'a, f32, UnitPowerLaw>

source§

fn from(stat: &'a UnitPowerLawSuffStat) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a UnitPowerLawSuffStat> for DataOrSuffStat<'a, f64, UnitPowerLaw>

source§

fn from(stat: &'a UnitPowerLawSuffStat) -> Self

Converts to this type from the input type.
source§

impl<'a, X> From<&'a Vec<X>> for DataOrSuffStat<'a, X, Bernoulli>
where X: Booleable,

source§

fn from(xs: &'a Vec<X>) -> Self

Converts to this type from the input type.
source§

impl<'a, X> From<&'a Vec<X>> for DataOrSuffStat<'a, X, Categorical>

source§

fn from(xs: &'a Vec<X>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<f32>> for DataOrSuffStat<'a, f32, Beta>

source§

fn from(xs: &'a Vec<f32>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<f32>> for DataOrSuffStat<'a, f32, Gaussian>

source§

fn from(xs: &'a Vec<f32>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<f32>> for DataOrSuffStat<'a, f32, InvGamma>

source§

fn from(xs: &'a Vec<f32>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<f32>> for DataOrSuffStat<'a, f32, InvGaussian>

source§

fn from(xs: &'a Vec<f32>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<f32>> for DataOrSuffStat<'a, f32, UnitPowerLaw>

source§

fn from(xs: &'a Vec<f32>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<f64>> for DataOrSuffStat<'a, f64, Beta>

source§

fn from(xs: &'a Vec<f64>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<f64>> for DataOrSuffStat<'a, f64, Gaussian>

source§

fn from(xs: &'a Vec<f64>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<f64>> for DataOrSuffStat<'a, f64, InvGamma>

source§

fn from(xs: &'a Vec<f64>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<f64>> for DataOrSuffStat<'a, f64, InvGaussian>

source§

fn from(xs: &'a Vec<f64>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<f64>> for DataOrSuffStat<'a, f64, UnitPowerLaw>

source§

fn from(xs: &'a Vec<f64>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<u16>> for DataOrSuffStat<'a, u16, Poisson>

source§

fn from(xs: &'a Vec<u16>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<u32>> for DataOrSuffStat<'a, u32, Poisson>

source§

fn from(xs: &'a Vec<u32>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<u8>> for DataOrSuffStat<'a, u8, Poisson>

source§

fn from(xs: &'a Vec<u8>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Vec<usize>> for DataOrSuffStat<'a, usize, Poisson>

source§

fn from(xs: &'a Vec<usize>) -> Self

Converts to this type from the input type.
source§

impl<'a, X, Fx> PartialEq 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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, X, Fx> StructuralPartialEq for DataOrSuffStat<'a, X, Fx>
where X: 'a, Fx: 'a + HasSuffStat<X>,

Auto Trait Implementations§

§

impl<'a, X, Fx> Freeze for DataOrSuffStat<'a, X, Fx>

§

impl<'a, X, Fx> RefUnwindSafe for DataOrSuffStat<'a, X, Fx>

§

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>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

source§

impl<T> SendAlias for T

source§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,

source§

impl<T> SyncAlias for T