[−][src]Struct rstat::Mixture
Probability distribution derived from a linear sum of random variables.
Examples
use rstat::{ Probability, Mixture, univariate::{normal::Normal, Moments} }; let gmm = Mixture::new( vec![0.2, 0.5, 0.3], vec![ Normal::new(-2.0, 1.2_f64.powi(2))?, Normal::new(0.0, 1.0_f64.powi(2))?, Normal::new(3.0, 2.5_f64.powi(2))?, ], )?; assert!((gmm.mean() - 0.5).abs() < 1e-7); assert!((gmm.variance() - 5.913).abs() < 1e-7); assert!((gmm.standard_deviation() - gmm.variance().sqrt()).abs() < 1e-7);
Fields
weights: SimplexVector
The weights of the linear sum.
components: Vec<C>
The distribution components of the linear sum.
Methods
impl<C: Distribution> Mixture<C>
[src]
pub fn new(weights: Vec<f64>, components: Vec<C>) -> Result<Mixture<C>, Error> where
C::Support: Union,
[src]
C::Support: Union,
pub fn new_unchecked(weights: Vec<f64>, components: Vec<C>) -> Mixture<C> where
C::Support: Union,
[src]
C::Support: Union,
pub fn n_components(&self) -> usize
[src]
Trait Implementations
impl<C: Clone + Distribution> Clone for Mixture<C> where
C::Support: Clone,
[src]
C::Support: Clone,
impl<C: ContinuousDistribution> ContinuousDistribution for Mixture<C> where
C::Support: Union + Clone,
[src]
C::Support: Union + Clone,
fn pdf(&self, x: &<Self::Support as Space>::Value) -> f64
[src]
fn log_pdf(&self, x: &Sample<Self>) -> f64
[src]
impl<C: Debug + Distribution> Debug for Mixture<C> where
C::Support: Debug,
[src]
C::Support: Debug,
impl<C: Distribution> Distribution for Mixture<C> where
C::Support: Union + Clone,
[src]
C::Support: Union + Clone,
type Support = C::Support
Support of sample elements.
type Params = Params<C::Params>
Parameter set uniquely defining the instance.
fn support(&self) -> Self::Support
[src]
fn params(&self) -> Params<C::Params>
[src]
fn cdf(&self, x: &<Self::Support as Space>::Value) -> Probability
[src]
fn sample<R: Rng + ?Sized>(
&self,
rng: &mut R
) -> <Self::Support as Space>::Value
[src]
&self,
rng: &mut R
) -> <Self::Support as Space>::Value
fn into_support(self) -> Self::Support
[src]
fn into_params(self) -> Self::Params
[src]
fn ccdf(&self, x: &Sample<Self>) -> Probability
[src]
fn log_cdf(&self, x: &Sample<Self>) -> f64
[src]
fn log_ccdf(&self, x: &Sample<Self>) -> f64
[src]
fn sample_n<R: Rng + ?Sized>(&self, rng: &mut R, n: usize) -> Vec<Sample<Self>>
[src]
fn sample_iter<'a, R: Rng + ?Sized>(
&'a self,
rng: &'a mut R
) -> Sampler<'a, Self, R>
[src]
&'a self,
rng: &'a mut R
) -> Sampler<'a, Self, R>
impl<C: UnivariateMoments> UnivariateMoments for Mixture<C> where
C::Support: Union + Clone,
[src]
C::Support: Union + Clone,
Auto Trait Implementations
impl<C> RefUnwindSafe for Mixture<C> where
C: RefUnwindSafe,
<C as Distribution>::Support: RefUnwindSafe,
C: RefUnwindSafe,
<C as Distribution>::Support: RefUnwindSafe,
impl<C> Send for Mixture<C> where
C: Send,
<C as Distribution>::Support: Send,
C: Send,
<C as Distribution>::Support: Send,
impl<C> Sync for Mixture<C> where
C: Sync,
<C as Distribution>::Support: Sync,
C: Sync,
<C as Distribution>::Support: Sync,
impl<C> Unpin for Mixture<C> where
C: Unpin,
<C as Distribution>::Support: Unpin,
C: Unpin,
<C as Distribution>::Support: Unpin,
impl<C> UnwindSafe for Mixture<C> where
C: UnwindSafe,
<C as Distribution>::Support: UnwindSafe,
C: UnwindSafe,
<C as Distribution>::Support: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,