Struct rv::dist::Categorical[][src]

pub struct Categorical {
    pub ln_weights: Vec<f64>,
}

Distribution over unordered values in [0, k)

Fields

Methods

impl Categorical
[src]

Construct a new Categorical distribution from weights

Examples

extern crate assert;
extern crate rv;

use rv::traits::*;
use rv::dist::Categorical;

let weights: Vec<f64> = vec![4.0, 2.0, 3.0, 1.0];
let cat = Categorical::new(&weights).unwrap();

assert!(cat.contains(&0_u8));
assert!(cat.contains(&3_u8));
assert!(!cat.contains(&4_u8));

assert::close(cat.pmf(&0_u8), 0.4, 10E-12);

Build a Categorical distribution from normalized log weights

Creates a Categorical distribution over [0, k) with uniform weights

Return the weights (exp(ln_weights))

Trait Implementations

impl Debug for Categorical
[src]

Formats the value using the given formatter. Read more

impl Clone for Categorical
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<X: CategoricalDatum> Rv<X> for Categorical
[src]

Un-normalized probability function Read more

The log of the constant term in the PDF/PMF. Should not be a function of any of the parameters. Read more

Single draw from the Rv Read more

Multiple draws of the Rv Read more

Un-normalized probability function Read more

The constant term in the PDF/PMF. Should not be a function of any of the parameters. Read more

impl<X: CategoricalDatum> Support<X> for Categorical
[src]

Returns true if x is in the support of the Rv Read more

impl<X: CategoricalDatum> DiscreteDistr<X> for Categorical
[src]

Probability mass function (PMF) at x Read more

Natural logarithm of the probability mass function (PMF) Read more

impl<X: CategoricalDatum> Mode<X> for Categorical
[src]

Returns None if the mode is undefined or is not a single value

impl Entropy for Categorical
[src]

The entropy, H(X)

impl<X: CategoricalDatum> HasSuffStat<X> for Categorical
[src]

impl Rv<Categorical> for SymmetricDirichlet
[src]

Un-normalized probability function Read more

The log of the constant term in the PDF/PMF. Should not be a function of any of the parameters. Read more

Single draw from the Rv Read more

Un-normalized probability function Read more

The constant term in the PDF/PMF. Should not be a function of any of the parameters. Read more

Multiple draws of the Rv Read more

impl<X: CategoricalDatum> ConjugatePrior<X, Categorical> for SymmetricDirichlet
[src]

Computes the posterior distribution from the data

Log marginal likelihood

Log posterior predictive of y given x

Marginal likelihood of x

Posterior Predictive distribution

impl Rv<Categorical> for Dirichlet
[src]

Un-normalized probability function Read more

The log of the constant term in the PDF/PMF. Should not be a function of any of the parameters. Read more

Single draw from the Rv Read more

Un-normalized probability function Read more

The constant term in the PDF/PMF. Should not be a function of any of the parameters. Read more

Multiple draws of the Rv Read more

impl<X: CategoricalDatum> ConjugatePrior<X, Categorical> for Dirichlet
[src]

Computes the posterior distribution from the data

Log marginal likelihood

Log posterior predictive of y given x

Marginal likelihood of x

Posterior Predictive distribution

Auto Trait Implementations

impl Send for Categorical

impl Sync for Categorical