Struct rv::dist::Dirichlet [−][src]
pub struct Dirichlet { /* fields omitted */ }
Dirichlet distribution over points on the k-simplex.
Implementations
impl Dirichlet
[src]
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<X: CategoricalDatum> ConjugatePrior<X, Categorical> 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
fn posterior(&self, x: &CategoricalData<'_, X>) -> Self::Posterior
[src]
fn ln_m_cache(&self) -> Self::LnMCache
[src]
fn ln_m_with_cache(
&self,
cache: &Self::LnMCache,
x: &CategoricalData<'_, X>
) -> f64
[src]
&self,
cache: &Self::LnMCache,
x: &CategoricalData<'_, X>
) -> f64
fn ln_pp_cache(&self, x: &CategoricalData<'_, X>) -> Self::LnPpCache
[src]
fn ln_pp_with_cache(&self, cache: &Self::LnPpCache, y: &X) -> f64
[src]
fn ln_m(&self, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
fn ln_pp(&self, y: &X, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
fn m(&self, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
fn pp(&self, y: &X, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
impl From<&'_ SymmetricDirichlet> for Dirichlet
[src]
impl From<&'_ SymmetricDirichlet> for Dirichlet
[src]fn from(symdir: &SymmetricDirichlet) -> Self
[src]
impl From<SymmetricDirichlet> for Dirichlet
[src]
impl From<SymmetricDirichlet> for Dirichlet
[src]fn from(symdir: SymmetricDirichlet) -> Self
[src]
impl Rv<Categorical> for Dirichlet
[src]
impl Rv<Categorical> for Dirichlet
[src]impl StructuralPartialEq for Dirichlet
[src]
impl StructuralPartialEq for Dirichlet
[src]Auto Trait Implementations
impl RefUnwindSafe for Dirichlet
impl RefUnwindSafe for Dirichlet
impl UnwindSafe for Dirichlet
impl UnwindSafe for Dirichlet
Blanket Implementations
impl<T> Same<T> for T
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<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn is_in_subset(&self) -> bool
pub fn to_subset_unchecked(&self) -> SS
pub fn from_subset(element: &SS) -> SP
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,