Trait statrs::distribution::Univariate [−][src]
The Univariate trait is used to specify an interface for univariate
distributions e.g. distributions that have a closed form cumulative
distribution
function
Required methods
fn cdf(&self, x: K) -> K[src]
Returns the cumulative distribution function calculated
at x for a given distribution. May panic depending
on the implementor.
Examples
use statrs::distribution::{Univariate, Uniform}; let n = Uniform::new(0.0, 1.0).unwrap(); assert_eq!(0.5, n.cdf(0.5));
Implementors
impl Univariate<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 Univariate<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 Univariate<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 Univariate<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 Univariate<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 Univariate<f64, f64> for Exponential[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 Univariate<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 Univariate<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 Univariate<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 Univariate<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 Univariate<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
impl Univariate<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 Univariate<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
impl Univariate<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 Univariate<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 Univariate<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
impl Univariate<i64, f64> for DiscreteUniform[src]
fn cdf(&self, x: f64) -> f64[src]
Calculates the cumulative distribution function for the
discrete uniform distribution at x
Formula
(floor(x) - min + 1) / (max - min + 1)
impl Univariate<u64, f64> for Bernoulli[src]
fn cdf(&self, x: f64) -> f64[src]
Calculates the cumulative distribution
function for the bernoulli distribution at x.
Formula
if x < 0 { 0 } else if x >= 1 { 1 } else { 1 - p }
impl Univariate<u64, f64> for Binomial[src]
fn cdf(&self, x: f64) -> f64[src]
Calulcates the cumulative distribution function for the
binomial distribution at x
Formula
I_(1 - p)(n - x, 1 + x)
where I_(x)(a, b) is the regularized incomplete beta function
impl Univariate<u64, f64> for Categorical[src]
fn cdf(&self, x: f64) -> f64[src]
Calculates the cumulative distribution function for the categorical
distribution at x
Formula
sum(p_j) from 0..x
where p_j is the probability mass for the jth category
impl Univariate<u64, f64> for Geometric[src]
fn cdf(&self, x: f64) -> f64[src]
Calculates the cumulative distribution function for the geometric
distribution at x
Formula
1 - (1 - p) ^ (x + 1)
impl Univariate<u64, f64> for Hypergeometric[src]
fn cdf(&self, x: f64) -> 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)
and p_F_q is the [generalized hypergeometric
function](https://en.wikipedia.
org/wiki/Generalized_hypergeometric_function)