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

pub struct Dirichlet { /* fields omitted */ }

Dirichlet distribution over points on the k-simplex.

Methods

impl Dirichlet[src]

pub fn new(alphas: Vec<f64>) -> Result<Self, DirichletError>[src]

Creates a Dirichlet with a given alphas vector

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

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]

impl From<SymmetricDirichlet> for Dirichlet[src]

impl PartialEq<Dirichlet> for Dirichlet[src]

impl PartialOrd<Dirichlet> for Dirichlet[src]

impl Rv<Categorical> for Dirichlet[src]

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

impl StructuralPartialEq for Dirichlet[src]

impl Support<Vec<f64>> 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<Fx, X> ContinuousDistr<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: ContinuousDistr<X>, 
[src]

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

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

impl<Fx, X> Rv<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Rv<X>, 
[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<Fx, X> Support<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Support<X>, 
[src]

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>,