Struct mix_distribution::Mix
source · pub struct Mix<T, U, X>where
T: Distribution<U>,
X: SampleUniform + PartialOrd,{ /* private fields */ }
Expand description
Mixture distribution.
Example
extern crate rand;
extern crate mix_distribution;
use rand::distributions::{Distribution, Normal};
use mix_distribution::Mix;
let mut rng = rand::thread_rng();
// Mixture of two distributions
let mix = {
let dists = vec![Normal::new(0.0, 1.0), Normal::new(1.0, 2.0)];
let weights = &[2, 1];
Mix::new(dists, weights)
};
mix.sample(&mut rng);
// Mixture of three distributions
let mix = {
let dists = vec![Normal::new(0.0, 1.0), Normal::new(1.0, 2.0), Normal::new(-1.0, 1.0)];
let weights = &[2, 1, 3];
Mix::new(dists, weights)
};
mix.sample(&mut rng);
Implementations
sourceimpl<T, U, X> Mix<T, U, X>where
T: Distribution<U>,
X: SampleUniform + PartialOrd,
impl<T, U, X> Mix<T, U, X>where
T: Distribution<U>,
X: SampleUniform + PartialOrd,
pub fn new<I, J>(dists: I, weights: J) -> Selfwhere
I: IntoIterator<Item = T>,
J: IntoIterator,
J::Item: SampleBorrow<X>,
X: for<'a> AddAssign<&'a X> + Clone + Default,
Trait Implementations
sourceimpl<T, U, X> Distribution<U> for Mix<T, U, X>where
T: Distribution<U>,
X: SampleUniform + PartialOrd,
impl<T, U, X> Distribution<U> for Mix<T, U, X>where
T: Distribution<U>,
X: SampleUniform + PartialOrd,
Auto Trait Implementations
impl<T, U, X> RefUnwindSafe for Mix<T, U, X>where
T: RefUnwindSafe,
U: RefUnwindSafe,
X: RefUnwindSafe,
<X as SampleUniform>::Sampler: RefUnwindSafe,
impl<T, U, X> Send for Mix<T, U, X>where
T: Send,
U: Send,
X: Send,
<X as SampleUniform>::Sampler: Send,
impl<T, U, X> Sync for Mix<T, U, X>where
T: Sync,
U: Sync,
X: Sync,
<X as SampleUniform>::Sampler: Sync,
impl<T, U, X> Unpin for Mix<T, U, X>where
T: Unpin,
U: Unpin,
X: Unpin,
<X as SampleUniform>::Sampler: Unpin,
impl<T, U, X> UnwindSafe for Mix<T, U, X>where
T: UnwindSafe,
U: UnwindSafe,
X: UnwindSafe,
<X as SampleUniform>::Sampler: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more