Struct rv::dist::Dirichlet[][src]

pub struct Dirichlet { /* fields omitted */ }

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

Type of the posterior distribution

type LnMCache = (f64, f64)

Type of the ln_m cache

type LnPpCache = (Vec<f64>, f64)

Type of the ln_pp cache

impl ContinuousDistr<Vec<f64, Global>> for Dirichlet[src]

impl Debug for Dirichlet[src]

impl Display for Dirichlet[src]

impl From<&'_ SymmetricDirichlet> for Dirichlet[src]

impl From<SymmetricDirichlet> for Dirichlet[src]

impl PartialEq<Dirichlet> for Dirichlet[src]

impl Rv<Categorical> for Dirichlet[src]

impl Rv<Vec<f64, Global>> for Dirichlet[src]

impl StructuralPartialEq for Dirichlet[src]

impl Support<Vec<f64, Global>> for Dirichlet[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,