[−][src]Trait rstat::DiscreteDistribution
Trait for distributions over a countable
Support
.
The PMF is defined as the probability that a random variable \(X\) takes a value exactly equal to \(x\), i.e. \(f(x) = P(X = x) = P(s \in S : X(s) = x)\). We require that all sum of probabilities over all possible outcomes sums to 1.
Provided methods
fn pmf(&self, x: &Sample<Self>) -> Probability
Evaluates the probability mass function (PMF) at \(x\).
Examples
let dist = Binomial::new_unchecked(5, Probability::new_unchecked(0.75)); assert_eq!(dist.pmf(&0), Probability::new_unchecked(0.0009765625)); assert_eq!(dist.pmf(&1), Probability::new_unchecked(0.0146484375)); assert_eq!(dist.pmf(&2), Probability::new_unchecked(0.087890625)); assert_eq!(dist.pmf(&3), Probability::new_unchecked(0.263671875)); assert_eq!(dist.pmf(&4), Probability::new_unchecked(0.3955078125)); assert_eq!(dist.pmf(&5), Probability::new_unchecked(0.2373046875));
fn log_pmf(&self, x: &Sample<Self>) -> f64
Evaluates the log PMF at \(x\).