Trait statrs::statistics::Mode[][src]

pub trait Mode<T> {
    fn mode(&self) -> T;
}
Expand description

The Mode trait specifies that an object has a closed form solution for its mode(s)

Required methods

fn mode(&self) -> T[src]

Expand description

Returns the mode, if one exists.

Examples

use statrs::statistics::Mode;
use statrs::distribution::Uniform;

let n = Uniform::new(0.0, 1.0).unwrap();
assert_eq!(Some(0.5), n.mode());

Implementors

impl Mode<Option<f64>> for Beta[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode of the Beta distribution.

Remarks

Since the mode is technically only calculate for α > 1, β > 1, those are the only values we allow. We may consider relaxing this constraint in the future.

Panics

If α <= 1 or β <= 1

Formula

(α - 1) / (α + β - 2)

where α is shapeA and β is shapeB

impl Mode<Option<f64>> for Cauchy[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode of the cauchy distribution

Formula

x_0

where x_0 is the location

impl Mode<Option<f64>> for Chi[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode for the chi distribution

Panics

If freedom < 1.0

Formula

sqrt(k - 1)

where k is the degrees of freedom

impl Mode<Option<f64>> for ChiSquared[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode of the chi-squared distribution

Formula

k - 2

where k is the degrees of freedom

impl Mode<Option<f64>> for Dirac[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode of the dirac distribution

Formula

v

where v is the point of the dirac distribution

impl Mode<Option<f64>> for Erlang[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode for the erlang distribution

Remarks

Returns shape if rate ==f64::INFINITY. This behavior is borrowed from the Math.NET implementation

Formula

(k - 1) / λ

where k is the shape and λ is the rate

impl Mode<Option<f64>> for Exp[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode of the exponential distribution

Formula

0

impl Mode<Option<f64>> for FisherSnedecor[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode for the fisher-snedecor distribution

Panics

If freedom_1 <= 2.0

Remarks

Returns NaN if freedom_1 or freedom_2 is INF

Formula

((d1 - 2) / d1) * (d2 / (d2 + 2))

where d1 is the first degree of freedom and d2 is the second degree of freedom

impl Mode<Option<f64>> for Gamma[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode for the gamma distribution

Formula

(α - 1) / β

where α is the shape and β is the rate

impl Mode<Option<f64>> for InverseGamma[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode of the inverse gamma distribution

Formula

β / (α + 1)

/// where α is the shape and β is the rate

impl Mode<Option<f64>> for Laplace[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode of the laplace distribution

Formula

μ

where μ is the location

impl Mode<Option<f64>> for LogNormal[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode of the log-normal distribution

Formula

e^(μ - σ^2)

where μ is the location and σ is the scale

impl Mode<Option<f64>> for NegativeBinomial[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode for the negative binomial distribution

Formula

if r > 1 then
    floor((r - 1) * (1-p / p))
else
    0

impl Mode<Option<f64>> for Normal[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode of the normal distribution

Formula

μ

where μ is the mean

impl Mode<Option<f64>> for Pareto[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode of the Pareto distribution

Formula

x_m

where x_m is the scale

impl Mode<Option<f64>> for StudentsT[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode of the student’s t-distribution

Formula

μ

where μ is the location

impl Mode<Option<f64>> for Triangular[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode of the triangular distribution

Formula

mode

impl Mode<Option<f64>> for Uniform[src]

fn mode(&self) -> Option<f64>[src]

Returns the mode for the continuous uniform distribution

Remarks

Since every element has an equal probability, mode simply returns the middle element

Formula

N/A // (max + min) / 2 for the middle element

impl Mode<Option<f64>> for Weibull[src]

fn mode(&self) -> Option<f64>[src]

Returns the median of the weibull distribution

Formula

if k == 1 {
    0
} else {
    λ((k - 1) / k)^(1 / k)
}

where k is the shape and λ is the scale

impl Mode<Option<i64>> for DiscreteUniform[src]

fn mode(&self) -> Option<i64>[src]

Returns the mode for the discrete uniform distribution

Remarks

Since every element has an equal probability, mode simply returns the middle element

Formula

N/A // (max + min) / 2 for the middle element

impl Mode<Option<u64>> for Bernoulli[src]

fn mode(&self) -> Option<u64>[src]

Returns the mode of the bernoulli distribution

Formula

if p < 0.5 { 0 }
else { 1 }

impl Mode<Option<u64>> for Binomial[src]

fn mode(&self) -> Option<u64>[src]

Returns the mode for the binomial distribution

Formula

floor((n + 1) * p)

impl Mode<Option<u64>> for Geometric[src]

fn mode(&self) -> Option<u64>[src]

Returns the mode of the geometric distribution

Formula

1

impl Mode<Option<u64>> for Hypergeometric[src]

fn mode(&self) -> Option<u64>[src]

Returns the mode of the hypergeometric distribution

Formula

floor((n + 1) * (k + 1) / (N + 2))

where N is population, K is successes, and n is draws

impl Mode<Option<u64>> for Poisson[src]

fn mode(&self) -> Option<u64>[src]

Returns the mode of the poisson distribution

Formula

floor(λ)

where λ is the rate

impl Mode<Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>> for MultivariateNormal[src]

fn mode(&self) -> DVector<f64>[src]

Returns the mode of the multivariate normal distribution

Formula

μ

where μ is the mean