Struct rand_distr::Dirichlet
source · [−]pub struct Dirichlet<F>where
F: Float,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,{ /* private fields */ }
Expand description
The Dirichlet distribution Dirichlet(alpha)
.
The Dirichlet distribution is a family of continuous multivariate probability distributions parameterized by a vector alpha of positive reals. It is a multivariate generalization of the beta distribution.
Example
use rand::prelude::*;
use rand_distr::Dirichlet;
let dirichlet = Dirichlet::new(&[1.0, 2.0, 3.0]).unwrap();
let samples = dirichlet.sample(&mut rand::thread_rng());
println!("{:?} is from a Dirichlet([1.0, 2.0, 3.0]) distribution", samples);
Implementations
sourceimpl<F> Dirichlet<F>where
F: Float,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
impl<F> Dirichlet<F>where
F: Float,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
sourcepub fn new(alpha: &[F]) -> Result<Dirichlet<F>, Error>
pub fn new(alpha: &[F]) -> Result<Dirichlet<F>, Error>
Construct a new Dirichlet
with the given alpha parameter alpha
.
Requires alpha.len() >= 2
.
sourcepub fn new_with_size(alpha: F, size: usize) -> Result<Dirichlet<F>, Error>
pub fn new_with_size(alpha: F, size: usize) -> Result<Dirichlet<F>, Error>
Construct a new Dirichlet
with the given shape parameter alpha
and size
.
Requires size >= 2
.
Trait Implementations
sourceimpl<F: Clone> Clone for Dirichlet<F>where
F: Float,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
impl<F: Clone> Clone for Dirichlet<F>where
F: Float,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
sourceimpl<F: Debug> Debug for Dirichlet<F>where
F: Float,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
impl<F: Debug> Debug for Dirichlet<F>where
F: Float,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
sourceimpl<F> Distribution<Vec<F, Global>> for Dirichlet<F>where
F: Float,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
impl<F> Distribution<Vec<F, Global>> for Dirichlet<F>where
F: Float,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
sourcefn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Vec<F>
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Vec<F>
Generate a random value of
T
, using rng
as the source of randomness.sourcefn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘNotable traits for DistIter<D, R, T>impl<D, R, T> Iterator for DistIter<D, R, T>where
D: Distribution<T>,
R: Rng, type Item = T;
where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘNotable traits for DistIter<D, R, T>impl<D, R, T> Iterator for DistIter<D, R, T>where
D: Distribution<T>,
R: Rng, type Item = T;
where
R: Rng,
D: Distribution<T>,
R: Rng, type Item = T;
Create an iterator that generates random values of
T
, using rng
as
the source of randomness. Read moreAuto Trait Implementations
impl<F> RefUnwindSafe for Dirichlet<F>where
F: RefUnwindSafe,
impl<F> Send for Dirichlet<F>where
F: Send,
impl<F> Sync for Dirichlet<F>where
F: Sync,
impl<F> Unpin for Dirichlet<F>
impl<F> UnwindSafe for Dirichlet<F>where
F: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ToOwned for Twhere
T: Clone,
impl<T> ToOwned for Twhere
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
fn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
Uses borrowed data to replace owned data, usually by cloning. Read more