pub struct Dirichlet<F, const N: usize>{ /* private fields */ }
Expand description
The Dirichlet distribution Dirichlet(α₁, α₂, ..., αₖ)
.
The Dirichlet distribution is a family of continuous multivariate
probability distributions parameterized by a vector of positive
real numbers α₁, α₂, ..., αₖ
, where k
is the number of dimensions
of the distribution. The distribution is supported on the k-1
-dimensional
simplex, which is the set of points x = [x₁, x₂, ..., xₖ]
such that
0 ≤ xᵢ ≤ 1
and ∑ xᵢ = 1
.
It is a multivariate generalization of the Beta
distribution.
The distribution is symmetric when all αᵢ
are equal.
§Plot
The following plot illustrates the 2-dimensional simplices for various 3-dimensional Dirichlet distributions.
§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::rng());
println!("{:?} is from a Dirichlet([1.0, 2.0, 3.0]) distribution", samples);
Implementations§
Trait Implementations§
Source§impl<F, const N: usize> Clone for Dirichlet<F, N>where
F: Float + Clone,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
impl<F, const N: usize> Clone for Dirichlet<F, N>where
F: Float + Clone,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
Source§impl<F, const N: usize> Debug for Dirichlet<F, N>where
F: Float + Debug,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
impl<F, const N: usize> Debug for Dirichlet<F, N>where
F: Float + Debug,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
Source§impl<F, const N: usize> Distribution<[F; N]> for Dirichlet<F, N>
impl<F, const N: usize> Distribution<[F; N]> for Dirichlet<F, N>
Source§impl<F, const N: usize> PartialEq for Dirichlet<F, N>where
F: Float + PartialEq,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
impl<F, const N: usize> PartialEq for Dirichlet<F, N>where
F: Float + PartialEq,
StandardNormal: Distribution<F>,
Exp1: Distribution<F>,
Open01: Distribution<F>,
impl<F, const N: usize> StructuralPartialEq for Dirichlet<F, N>
Auto Trait Implementations§
impl<F, const N: usize> Freeze for Dirichlet<F, N>where
F: Freeze,
impl<F, const N: usize> RefUnwindSafe for Dirichlet<F, N>where
F: RefUnwindSafe,
impl<F, const N: usize> Send for Dirichlet<F, N>where
F: Send,
impl<F, const N: usize> Sync for Dirichlet<F, N>where
F: Sync,
impl<F, const N: usize> Unpin for Dirichlet<F, N>where
F: Unpin,
impl<F, const N: usize> UnwindSafe for Dirichlet<F, N>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more