[−][src]Struct rv::dist::Dirichlet
Dirichlet distribution over points on the k-simplex.
Implementations
impl Dirichlet
[src]
pub fn new(alphas: Vec<f64>) -> Result<Self, DirichletError>
[src]
Creates a Dirichlet
with a given alphas
vector
pub fn new_unchecked(alphas: Vec<f64>) -> Self
[src]
Creates a new Dirichlet without checking whether the parameters are valid.
pub fn symmetric(alpha: f64, k: usize) -> Result<Self, DirichletError>
[src]
Creates a Dirichlet
where all alphas are identical.
Notes
SymmetricDirichlet
if faster and more compact, and is the preferred
way to represent a Dirichlet symmetric weights.
Examples
let dir = Dirichlet::symmetric(1.0, 4).unwrap(); assert_eq!(*dir.alphas(), vec![1.0, 1.0, 1.0, 1.0]); // Equivalent to SymmetricDirichlet let symdir = SymmetricDirichlet::new(1.0, 4).unwrap(); let x: Vec<f64> = vec![0.1, 0.4, 0.3, 0.2]; assert::close(dir.ln_f(&x), symdir.ln_f(&x), 1E-12);
pub fn jeffreys(k: usize) -> Result<Self, DirichletError>
[src]
Creates a Dirichlet
with all alphas = 0.5 (Jeffreys prior)
Notes
SymmetricDirichlet
if faster and more compact, and is the preferred
way to represent a Dirichlet symmetric weights.
Examples
let dir = Dirichlet::jeffreys(3).unwrap(); assert_eq!(*dir.alphas(), vec![0.5, 0.5, 0.5]); // Equivalent to SymmetricDirichlet::jeffreys let symdir = SymmetricDirichlet::jeffreys(3).unwrap(); let x: Vec<f64> = vec![0.1, 0.4, 0.5]; assert::close(dir.ln_f(&x), symdir.ln_f(&x), 1E-12);
pub fn k(&self) -> usize
[src]
The length of alphas
/ the number of categories
pub fn alphas(&self) -> &Vec<f64>
[src]
Get a reference to the weights vector, alphas
Trait Implementations
impl Clone for Dirichlet
[src]
impl<X: CategoricalDatum> ConjugatePrior<X, Categorical> for Dirichlet
[src]
type Posterior = Self
fn posterior(&self, x: &CategoricalData<X>) -> Self::Posterior
[src]
fn ln_m(&self, x: &CategoricalData<X>) -> f64
[src]
fn ln_pp(&self, y: &X, x: &CategoricalData<X>) -> f64
[src]
fn m(&self, x: &DataOrSuffStat<X, Fx>) -> f64
[src]
fn pp(&self, y: &X, x: &DataOrSuffStat<X, Fx>) -> f64
[src]
impl ContinuousDistr<Vec<f64>> for Dirichlet
[src]
impl Debug for Dirichlet
[src]
impl Display for Dirichlet
[src]
impl<'_> From<&'_ Dirichlet> for String
[src]
impl<'_> From<&'_ SymmetricDirichlet> for Dirichlet
[src]
fn from(symdir: &SymmetricDirichlet) -> Self
[src]
impl From<SymmetricDirichlet> for Dirichlet
[src]
fn from(symdir: SymmetricDirichlet) -> Self
[src]
impl PartialEq<Dirichlet> for Dirichlet
[src]
impl Rv<Categorical> for Dirichlet
[src]
fn ln_f(&self, x: &Categorical) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> Categorical
[src]
fn f(&self, x: &X) -> f64
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
fn sample_stream<'r, R: Rng>(
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
[src]
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
impl Rv<Vec<f64>> for Dirichlet
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> Vec<f64>
[src]
fn ln_f(&self, x: &Vec<f64>) -> f64
[src]
fn f(&self, x: &X) -> f64
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
fn sample_stream<'r, R: Rng>(
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
[src]
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
impl StructuralPartialEq for Dirichlet
[src]
impl Support<Vec<f64>> for Dirichlet
[src]
Auto Trait Implementations
impl RefUnwindSafe for Dirichlet
impl Send for Dirichlet
impl Sync for Dirichlet
impl Unpin for Dirichlet
impl UnwindSafe for Dirichlet
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Fx, X> ContinuousDistr<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: ContinuousDistr<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: ContinuousDistr<X>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<Fx, X> Rv<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Rv<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Rv<X>,
fn ln_f(&Self, &X) -> f64
[src]
fn f(&Self, &X) -> f64
[src]
fn draw<R>(&Self, &mut R) -> X where
R: Rng,
[src]
R: Rng,
fn sample<R>(&Self, usize, &mut R) -> Vec<X> where
R: Rng,
[src]
R: Rng,
fn sample_stream<'r, R: Rng>(
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
[src]
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
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>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<Fx, X> Support<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Support<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Support<X>,
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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,