pub trait DiscreteCDF<K: Sized + Num + Ord + Clone + NumAssignOps, T: Float>: Min<K> + Max<K> {
// Required method
fn cdf(&self, x: K) -> T;
// Provided methods
fn sf(&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§
Provided Methods§
Sourcefn sf(&self, x: K) -> T
fn sf(&self, x: K) -> T
Returns the survival function calculated at x
for
a given distribution. May panic depending on the implementor.
§Examples
use statrs::distribution::{DiscreteCDF, DiscreteUniform};
let n = DiscreteUniform::new(1, 10).unwrap();
assert_eq!(0.4, n.sf(6));
Sourcefn inverse_cdf(&self, p: T) -> K
fn inverse_cdf(&self, p: T) -> K
Due to issues with rounding and floating-point accuracy the default implementation may be ill-behaved Specialized inverse cdfs should be used whenever possible.
§Panics
this default impl panics if provided p
not on interval [0.0, 1.0]