Trait statrs::distribution::DiscreteCDF [−][src]
pub trait DiscreteCDF<K: Bounded + Clone + Num, T: Float>: Min<K> + Max<K> { fn cdf(&self, x: K) -> T; fn inverse_cdf(&self, p: T) -> K { ... } }
Expand description
The DiscreteCDF
trait is used to specify an interface for univariate
discrete distributions.
Required methods
fn cdf(&self, x: K) -> T
[src]
Expand description
Returns the cumulative distribution function calculated
at x
for a given distribution. May panic depending
on the implementor.
Examples
use statrs::distribution::{ContinuousCDF, Uniform}; let n = Uniform::new(0.0, 1.0).unwrap(); assert_eq!(0.5, n.cdf(0.5));
Provided methods
fn inverse_cdf(&self, p: T) -> K
[src]
Expand description
Due to issues with rounding and floating-point accuracy the default implementation may be ill-behaved Specialized inverse cdfs should be used whenever possible.
Implementors
impl DiscreteCDF<i64, f64> for DiscreteUniform
[src]
impl DiscreteCDF<i64, f64> for DiscreteUniform
[src]impl DiscreteCDF<u64, f64> for Bernoulli
[src]
impl DiscreteCDF<u64, f64> for Bernoulli
[src]impl DiscreteCDF<u64, f64> for Binomial
[src]
impl DiscreteCDF<u64, f64> for Binomial
[src]impl DiscreteCDF<u64, f64> for Categorical
[src]
impl DiscreteCDF<u64, f64> for Categorical
[src]impl DiscreteCDF<u64, f64> for Geometric
[src]
impl DiscreteCDF<u64, f64> for Geometric
[src]impl DiscreteCDF<u64, f64> for Hypergeometric
[src]
impl DiscreteCDF<u64, f64> for Hypergeometric
[src]fn cdf(&self, x: u64) -> f64
[src]
fn cdf(&self, x: u64) -> f64
[src]Calculates the cumulative distribution function for the hypergeometric
distribution at x
Formula
1 - ((n choose k+1) * (N-n choose K-k-1)) / (N choose K) * 3_F_2(1, k+1-K, k+1-n; k+2, N+k+2-K-n; 1)
where N
is population, K
is successes, n
is draws,
and p_F_q
is the [generalized hypergeometric
function](https://en.wikipedia.
org/wiki/Generalized_hypergeometric_function)
impl DiscreteCDF<u64, f64> for NegativeBinomial
[src]
impl DiscreteCDF<u64, f64> for NegativeBinomial
[src]fn cdf(&self, x: u64) -> f64
[src]
fn cdf(&self, x: u64) -> f64
[src]Calculates the cumulative distribution function for the
negative binomial distribution at x
Note that due to extending the distribution to the reals
(allowing positive real values for r
), while still technically
a discrete distribution the CDF behaves more like that of a
continuous distribution rather than a discrete distribution
(i.e. a smooth graph rather than a step-ladder)
Formula
1 - I_(1 - p)(x + 1, r)
where I_(x)(a, b)
is the regularized incomplete beta function