Struct rv::dist::Dirichlet [−][src]
Dirichlet distribution over points on the k-simplex
Fields
alphas: Vec<f64>
A Vec
of real numbers in (0, ∞)
Methods
impl Dirichlet
[src]
impl Dirichlet
pub fn new(alphas: Vec<f64>) -> Result<Self>
[src]
pub fn new(alphas: Vec<f64>) -> Result<Self>
Creates a Dirichlet
with a given alphas
vector
pub fn symmetric(alpha: f64, k: usize) -> Self
[src]
pub fn symmetric(alpha: f64, k: usize) -> Self
Creates a Dirichlet
where all alphas are identical
Eaxmples
let dir = Dirichlet::symmetric(1.0, 4); assert_eq!(dir.alphas, vec![1.0, 1.0, 1.0, 1.0]);
pub fn jeffreys(k: usize) -> Self
[src]
pub fn jeffreys(k: usize) -> Self
Creates a Dirichlet
with all alphas = 0.5 (Feffreys prior)
Eaxmples
let dir = Dirichlet::jeffreys(3); assert_eq!(dir.alphas, vec![0.5, 0.5, 0.5]);
pub fn k(&self) -> usize
[src]
pub fn k(&self) -> usize
The length of alphas
/ the number of categories
Trait Implementations
impl Debug for Dirichlet
[src]
impl Debug for Dirichlet
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for Dirichlet
[src]
impl Clone for Dirichlet
fn clone(&self) -> Dirichlet
[src]
fn clone(&self) -> Dirichlet
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Rv<Vec<f64>> for Dirichlet
[src]
impl Rv<Vec<f64>> for Dirichlet
fn draw<R: Rng>(&self, rng: &mut R) -> Vec<f64>
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> Vec<f64>
Single draw from the Rv
Read more
fn ln_normalizer(&self) -> f64
[src]
fn ln_normalizer(&self) -> f64
The log of the constant term in the PDF/PMF. Should not be a function of any of the parameters. Read more
fn ln_f(&self, x: &Vec<f64>) -> f64
[src]
fn ln_f(&self, x: &Vec<f64>) -> f64
Un-normalized probability function Read more
fn f(&self, x: &X) -> f64
[src]
fn f(&self, x: &X) -> f64
Un-normalized probability function Read more
fn normalizer(&self) -> f64
[src]
fn normalizer(&self) -> f64
The constant term in the PDF/PMF. Should not be a function of any of the parameters. Read more
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
Multiple draws of the Rv
Read more
impl ContinuousDistr<Vec<f64>> for Dirichlet
[src]
impl ContinuousDistr<Vec<f64>> for Dirichlet
fn pdf(&self, x: &X) -> f64
[src]
fn pdf(&self, x: &X) -> f64
The value of the Probability Density Function (PDF) at x
Read more
fn ln_pdf(&self, x: &X) -> f64
[src]
fn ln_pdf(&self, x: &X) -> f64
The value of the log Probability Density Function (PDF) at x
Read more
impl Support<Vec<f64>> for Dirichlet
[src]
impl Support<Vec<f64>> for Dirichlet
fn contains(&self, x: &Vec<f64>) -> bool
[src]
fn contains(&self, x: &Vec<f64>) -> bool
Returns true
if x
is in the support of the Rv
Read more
impl Rv<Categorical> for Dirichlet
[src]
impl Rv<Categorical> for Dirichlet
fn ln_f(&self, x: &Categorical) -> f64
[src]
fn ln_f(&self, x: &Categorical) -> f64
Un-normalized probability function Read more
fn ln_normalizer(&self) -> f64
[src]
fn ln_normalizer(&self) -> f64
The log of the constant term in the PDF/PMF. Should not be a function of any of the parameters. Read more
fn draw<R: Rng>(&self, rng: &mut R) -> Categorical
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> Categorical
Single draw from the Rv
Read more
fn f(&self, x: &X) -> f64
[src]
fn f(&self, x: &X) -> f64
Un-normalized probability function Read more
fn normalizer(&self) -> f64
[src]
fn normalizer(&self) -> f64
The constant term in the PDF/PMF. Should not be a function of any of the parameters. Read more
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
Multiple draws of the Rv
Read more
impl<X: CategoricalDatum> ConjugatePrior<X, Categorical> for Dirichlet
[src]
impl<X: CategoricalDatum> ConjugatePrior<X, Categorical> for Dirichlet
type Posterior = Self
fn posterior(&self, x: &CategoricalData<X>) -> Self::Posterior
[src]
fn posterior(&self, x: &CategoricalData<X>) -> Self::Posterior
Computes the posterior distribution from the data
fn ln_m(&self, x: &CategoricalData<X>) -> f64
[src]
fn ln_m(&self, x: &CategoricalData<X>) -> f64
Log marginal likelihood
fn ln_pp(&self, y: &X, x: &CategoricalData<X>) -> f64
[src]
fn ln_pp(&self, y: &X, x: &CategoricalData<X>) -> f64
Log posterior predictive of y given x
fn m(&self, x: &DataOrSuffStat<X, Fx>) -> f64
[src]
fn m(&self, x: &DataOrSuffStat<X, Fx>) -> f64
Marginal likelihood of x
fn pp(&self, y: &X, x: &DataOrSuffStat<X, Fx>) -> f64
[src]
fn pp(&self, y: &X, x: &DataOrSuffStat<X, Fx>) -> f64
Posterior Predictive distribution