pub trait Discrete<K, T> {
// Required methods
fn pmf(&self, x: K) -> T;
fn ln_pmf(&self, x: K) -> T;
}
Expand description
The Discrete
trait provides an interface for interacting with discrete
statistical distributions
§Remarks
All methods provided by the Discrete
trait are unchecked, meaning
they can panic if in an invalid state or encountering invalid input
depending on the implementing distribution.
Required Methods§
Sourcefn pmf(&self, x: K) -> T
fn pmf(&self, x: K) -> T
Returns the probability mass function calculated at x
for a given
distribution.
May panic depending on the implementor.
§Examples
use statrs::distribution::{Discrete, Binomial};
use statrs::prec;
let n = Binomial::new(0.5, 10).unwrap();
assert!(prec::almost_eq(n.pmf(5), 0.24609375, 1e-15));
Sourcefn ln_pmf(&self, x: K) -> T
fn ln_pmf(&self, x: K) -> T
Returns the log of the probability mass function calculated at x
for
a given distribution.
May panic depending on the implementor.
§Examples
use statrs::distribution::{Discrete, Binomial};
use statrs::prec;
let n = Binomial::new(0.5, 10).unwrap();
assert!(prec::almost_eq(n.ln_pmf(5), (0.24609375f64).ln(), 1e-15));
Implementors§
impl Discrete<i64, f64> for DiscreteUniform
impl Discrete<u64, f64> for Bernoulli
impl Discrete<u64, f64> for Binomial
impl Discrete<u64, f64> for Categorical
impl Discrete<u64, f64> for Geometric
impl Discrete<u64, f64> for Hypergeometric
impl Discrete<u64, f64> for NegativeBinomial
impl Discrete<u64, f64> for Poisson
impl<D> Discrete<&Matrix<u64, D, Const<1>, <DefaultAllocator as Allocator<D>>::Buffer<u64>>, f64> for Multinomial<D>
Available on crate feature
nalgebra
only.