Trait statrs::distribution::InverseCDF[][src]

pub trait InverseCDF<T> {
    fn inverse_cdf(&self, x: T) -> T;
}

The InverseCDF trait is used to specify an interface for distributions with a closed form solution to the inverse cumulative distribution function. This trait will probably be merged into Univariate in a future release when already implemented distributions have InverseCDF back ported

Required methods

fn inverse_cdf(&self, x: T) -> T[src]

Returns the inverse cumulative distribution function calculated at x for a given distribution. May panic depending on the implementor.

Examples

use statrs::distribution::InverseCDF;
use statrs::distribution::Categorical;

let n = Categorical::new(&[0.0, 1.0, 2.0]).unwrap();
assert_eq!(n.inverse_cdf(0.5), 2.0);
Loading content...

Implementors

impl InverseCDF<f64> for Categorical[src]

fn inverse_cdf(&self, x: f64) -> f64[src]

Calculates the inverse cumulative distribution function for the categorical distribution at x

Panics

If x <= 0.0 or x >= 1.0

Formula

i

where i is the first index such that x < f(i) and f(x) is defined as p_x + f(x - 1) and f(0) = p_0 where p_x is the xth probability mass

impl InverseCDF<f64> for Normal[src]

fn inverse_cdf(&self, x: f64) -> f64[src]

Calculates the inverse cumulative distribution function for the normal distribution at x

Panics

If x < 0.0 or x > 1.0

Formula

μ - sqrt(2) * σ * erfc_inv(2x)

where μ is the mean, σ is the standard deviation and erfc_inv is the inverse of the complementary error function

Loading content...