[−][src]Struct rv::dist::Mixture
Mixture distribution Σ wi f(x|θi)
A mixture distribution is a convex combination of distributions.
Example
A bimodal Gaussian mixture model
use rv::prelude::*; let g1 = Gaussian::new(-2.5, 1.0).unwrap(); let g2 = Gaussian::new(2.0, 2.1).unwrap(); // f(x) = 0.6 * N(-2.5, 1.0) + 0.4 * N(2.0, 2.1) let mm = Mixture::new(vec![0.6, 0.4], vec![g1, g2]).unwrap();
Fields
weights: Vec<f64>
The weights for each component distribution. All entries must be positive and sum to 1.
components: Vec<Fx>
The component distributions.
Methods
impl<Fx: ApiReady> Mixture<Fx>
[src]
pub fn new(weights: Vec<f64>, components: Vec<Fx>) -> Result<Self>
[src]
pub fn uniform(components: Vec<Fx>) -> Result<Self>
[src]
Assume uniform component weights
Given a n-length vector of components, automatically sets the component weights to 1/n.
pub fn combine(mixtures: Vec<Mixture<Fx>>) -> Result<Self>
[src]
Combines many mixtures into one big mixture
pub fn k(&self) -> usize
[src]
Number of components
Trait Implementations
impl<X, Fx> Rv<X> for Mixture<Fx> where
Fx: Rv<X> + ApiReady,
[src]
Fx: Rv<X> + ApiReady,
fn ln_f(&self, x: &X) -> f64
[src]
fn f(&self, x: &X) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> X
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
impl<X, Fx> Support<X> for Mixture<Fx> where
Fx: Rv<X> + Support<X> + ApiReady,
[src]
Fx: Rv<X> + Support<X> + ApiReady,
impl<X, Fx> ContinuousDistr<X> for Mixture<Fx> where
Fx: Rv<X> + ContinuousDistr<X> + ApiReady,
[src]
Fx: Rv<X> + ContinuousDistr<X> + ApiReady,
impl<X, Fx> Cdf<X> for Mixture<Fx> where
Fx: Rv<X> + Cdf<X> + ApiReady,
[src]
Fx: Rv<X> + Cdf<X> + ApiReady,
impl<X, Fx> DiscreteDistr<X> for Mixture<Fx> where
Fx: Rv<X> + DiscreteDistr<X> + ApiReady,
[src]
Fx: Rv<X> + DiscreteDistr<X> + ApiReady,
impl<Fx> Mean<f32> for Mixture<Fx> where
Fx: ContinuousDistr<f32> + Mean<f32> + ApiReady,
[src]
Fx: ContinuousDistr<f32> + Mean<f32> + ApiReady,
impl<Fx> Mean<f64> for Mixture<Fx> where
Fx: ContinuousDistr<f64> + Mean<f64> + ApiReady,
[src]
Fx: ContinuousDistr<f64> + Mean<f64> + ApiReady,
impl<Fx> Variance<f32> for Mixture<Fx> where
Fx: ContinuousDistr<f32> + Mean<f32> + Variance<f32> + ApiReady,
[src]
Fx: ContinuousDistr<f32> + Mean<f32> + Variance<f32> + ApiReady,
impl<Fx> Variance<f64> for Mixture<Fx> where
Fx: ContinuousDistr<f64> + Mean<f64> + Variance<f64> + ApiReady,
[src]
Fx: ContinuousDistr<f64> + Mean<f64> + Variance<f64> + ApiReady,
impl Entropy for Mixture<Categorical>
[src]
impl Entropy for Mixture<Mixture<Categorical>>
[src]
impl Entropy for Mixture<Gaussian>
[src]
impl Entropy for Mixture<Mixture<Gaussian>>
[src]
impl<Fx: PartialOrd + ApiReady> PartialOrd<Mixture<Fx>> for Mixture<Fx>
[src]
fn partial_cmp(&self, other: &Mixture<Fx>) -> Option<Ordering>
[src]
fn lt(&self, other: &Mixture<Fx>) -> bool
[src]
fn le(&self, other: &Mixture<Fx>) -> bool
[src]
fn gt(&self, other: &Mixture<Fx>) -> bool
[src]
fn ge(&self, other: &Mixture<Fx>) -> bool
[src]
impl<Fx: PartialEq + ApiReady> PartialEq<Mixture<Fx>> for Mixture<Fx>
[src]
impl<Fx: Clone + ApiReady> Clone for Mixture<Fx>
[src]
fn clone(&self) -> Mixture<Fx>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<Fx: Debug + ApiReady> Debug for Mixture<Fx>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ApiReady for T where
T: Clone + Debug + PartialOrd<T> + PartialEq<T>,
[src]
T: Clone + Debug + PartialOrd<T> + PartialEq<T>,
impl<T> From<T> for T
[src]
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> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,