Trait statrs::distribution::CheckedDiscrete [−][src]
pub trait CheckedDiscrete<T, K> {
fn checked_pmf(&self, x: T) -> Result<K>;
fn checked_ln_pmf(&self, x: T) -> Result<K>;
}The CheckedDiscrete trait provides an interface for interacting
with discrete statistical distributions with possible failure modes
Required methods
fn checked_pmf(&self, x: T) -> Result<K>[src]
Returns the probability mass function calculated at x for a given
distribution.
Examples
use statrs::distribution::{CheckedDiscrete, Multinomial}; use statrs::prec; let n = Multinomial::new(&[0.3, 0.7], 5).unwrap(); assert!(n.checked_pmf(&[1]).is_err());
fn checked_ln_pmf(&self, x: T) -> Result<K>[src]
Returns the log of the probability mass function calculated at x for
a given distribution.
Examples
use statrs::distribution::{CheckedDiscrete, Multinomial}; use statrs::prec; let n = Multinomial::new(&[0.3, 0.7], 5).unwrap(); assert!(n.checked_ln_pmf(&[1]).is_err());
Implementors
impl<'a> CheckedDiscrete<&'a [u64], f64> for Multinomial[src]
impl<'a> CheckedDiscrete<&'a [u64], f64> for Multinomial[src]fn checked_pmf(&self, x: &[u64]) -> Result<f64>[src]
Calculates the probability mass function for the multinomial
distribution
with the given x’s corresponding to the probabilities for this
distribution
Errors
If the elements in x do not sum to n or if the length of x is not
equivalent to the length of p
Formula
(n! / x_1!...x_k!) * p_i^x_i for i in 1...k
where n is the number of trials, p_i is the ith probability,
x_i is the ith x value, and k is the total number of
probabilities
fn checked_ln_pmf(&self, x: &[u64]) -> Result<f64>[src]
Calculates the log probability mass function for the multinomial
distribution
with the given x’s corresponding to the probabilities for this
distribution
Errors
If the elements in x do not sum to n or if the length of x is not
equivalent to the length of p
Formula
ln((n! / x_1!...x_k!) * p_i^x_i) for i in 1...k
where n is the number of trials, p_i is the ith probability,
x_i is the ith x value, and k is the total number of
probabilities