[][src]Struct rstat::Mixture

pub struct Mixture<C: Distribution> {
    pub weights: SimplexVector,
    pub components: Vec<C>,
    // some fields omitted
}

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]

pub fn new_unchecked(weights: Vec<f64>, components: Vec<C>) -> Mixture<C> where
    C::Support: Union
[src]

pub fn n_components(&self) -> usize[src]

Trait Implementations

impl<C: Clone + Distribution> Clone for Mixture<C> where
    C::Support: Clone
[src]

impl<C: ContinuousDistribution> ContinuousDistribution for Mixture<C> where
    C::Support: Union + Clone
[src]

impl<C: Debug + Distribution> Debug for Mixture<C> where
    C::Support: Debug
[src]

impl<C: Distribution> Distribution for Mixture<C> where
    C::Support: Union + Clone
[src]

type Support = C::Support

Support of sample elements.

type Params = Params<C::Params>

Parameter set uniquely defining the instance.

impl<C: UnivariateMoments> UnivariateMoments for Mixture<C> where
    C::Support: Union + Clone
[src]

Auto Trait Implementations

impl<C> RefUnwindSafe for Mixture<C> where
    C: RefUnwindSafe,
    <C as Distribution>::Support: RefUnwindSafe

impl<C> Send for Mixture<C> where
    C: Send,
    <C as Distribution>::Support: Send

impl<C> Sync for Mixture<C> where
    C: Sync,
    <C as Distribution>::Support: Sync

impl<C> Unpin for Mixture<C> where
    C: Unpin,
    <C as Distribution>::Support: Unpin

impl<C> UnwindSafe for Mixture<C> where
    C: UnwindSafe,
    <C as Distribution>::Support: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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