Trait statrs::distribution::ContinuousCDF[][src]

pub trait ContinuousCDF<K: Float, T: Float>: Min<K> + Max<K> {
    fn cdf(&self, x: K) -> T;

    fn inverse_cdf(&self, p: T) -> K { ... }
}
Expand description

The ContinuousCDF trait is used to specify an interface for univariate distributions for which cdf float arguments are sensible.

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. Performs a binary search on the domain of cdf to obtain an approximation of F^-1(p) := inf { x | F(x) >= p }. Needless to say, performance may may be lacking.

Implementors

impl ContinuousCDF<f64, f64> for Beta[src]

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

Calculates the cumulative distribution function for the beta distribution at x

Formula

I_x(α, β)

where α is shapeA, β is shapeB, and I_x is the regularized lower incomplete beta function

impl ContinuousCDF<f64, f64> for Cauchy[src]

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

Calculates the cumulative distribution function for the cauchy distribution at x

Formula

(1 / π) * arctan((x - x_0) / γ) + 0.5

where x_0 is the location and γ is the scale

impl ContinuousCDF<f64, f64> for Chi[src]

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

Calculates the cumulative distribution function for the chi distribution at x.

Formula

P(k / 2, x^2 / 2)

where k is the degrees of freedom and P is the regularized Gamma function

impl ContinuousCDF<f64, f64> for ChiSquared[src]

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

Calculates the cumulative distribution function for the chi-squared distribution at x

Formula

(1 / Γ(k / 2)) * γ(k / 2, x / 2)

where k is the degrees of freedom, Γ is the gamma function, and γ is the lower incomplete gamma function

impl ContinuousCDF<f64, f64> for Dirac[src]

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

Calculates the cumulative distribution function for the dirac distribution at x

Where the value is 1 if x > v, 0 otherwise.

impl ContinuousCDF<f64, f64> for Empirical[src]

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

impl ContinuousCDF<f64, f64> for Erlang[src]

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

Calculates the cumulative distribution function for the erlang distribution at x

Formula

γ(k, λx)  (k - 1)!

where k is the shape, λ is the rate, and γ is the lower incomplete gamma function

impl ContinuousCDF<f64, f64> for Exp[src]

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

Calculates the cumulative distribution function for the exponential distribution at x

Formula

1 - e^(-λ * x)

where λ is the rate

impl ContinuousCDF<f64, f64> for FisherSnedecor[src]

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

Calculates the cumulative distribution function for the fisher-snedecor distribution at x

Formula

I_((d1 * x) / (d1 * x + d2))(d1 / 2, d2 / 2)

where d1 is the first degree of freedom, d2 is the second degree of freedom, and I is the regularized incomplete beta function

impl ContinuousCDF<f64, f64> for Gamma[src]

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

Calculates the cumulative distribution function for the gamma distribution at x

Formula

(1 / Γ(α)) * γ(α, β * x)

where α is the shape, β is the rate, Γ is the gamma function, and γ is the lower incomplete gamma function

impl ContinuousCDF<f64, f64> for InverseGamma[src]

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

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

Formula

Γ(α, β / x) / Γ(α)

where the numerator is the upper incomplete gamma function, the denominator is the gamma function, α is the shape, and β is the rate

impl ContinuousCDF<f64, f64> for Laplace[src]

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

Calculates the cumulative distribution function for the laplace distribution at x

Formula

(1 / 2) * (1 + signum(x - μ)) - signum(x - μ) * exp(-|x - μ| / b)

where μ is the location, b is the scale

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

Calculates the inverse cumulative distribution function for the laplace distribution at p

Formula

if p <= 1/2

μ + b * ln(2p)

if p >= 1/2

μ - b * ln(2 - 2p)

where μ is the location, b is the scale

impl ContinuousCDF<f64, f64> for LogNormal[src]

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

Calculates the cumulative distribution function for the log-normal distribution at x

Formula

(1 / 2) + (1 / 2) * erf((ln(x) - μ) / sqrt(2) * σ)

where μ is the location, σ is the scale, and erf is the error function

impl ContinuousCDF<f64, f64> for Normal[src]

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

Calculates the cumulative distribution function for the normal distribution at x

Formula

(1 / 2) * (1 + erf((x - μ) / (σ * sqrt(2))))

where μ is the mean, σ is the standard deviation, and erf is the error function

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

impl ContinuousCDF<f64, f64> for Pareto[src]

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

Calculates the cumulative distribution function for the Pareto distribution at x

Formula

if x < x_m {
    0
} else {
    1 - (x_m/x)^α
}

where x_m is the scale and α is the shape

impl ContinuousCDF<f64, f64> for StudentsT[src]

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

Calculates the cumulative distribution function for the student’s t-distribution at x

Formula

if x < μ {
    (1 / 2) * I(t, v / 2, 1 / 2)
} else {
    1 - (1 / 2) * I(t, v / 2, 1 / 2)
}

where t = v / (v + k^2), k = (x - μ) / σ, μ is the location, σ is the scale, v is the freedom, and I is the regularized incomplete beta function

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

Calculates the inverse cumulative distribution function for the Student’s T-distribution at x

impl ContinuousCDF<f64, f64> for Triangular[src]

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

Calculates the cumulative distribution function for the triangular distribution at x

Formula

if x == min {
    0
} if min < x <= mode {
    (x - min)^2 / ((max - min) * (mode - min))
} else if mode < x < max {
    1 - (max - min)^2 / ((max - min) * (max - mode))
} else {
    1
}

impl ContinuousCDF<f64, f64> for Uniform[src]

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

Calculates the cumulative distribution function for the uniform distribution at x

Formula

(x - min) / (max - min)

impl ContinuousCDF<f64, f64> for Weibull[src]

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

Calculates the cumulative distribution function for the weibull distribution at x

Formula

1 - e^-((x/λ)^k)

where k is the shape and λ is the scale