Trait statrs::statistics::Entropy[][src]

pub trait Entropy<T> {
    fn entropy(&self) -> T;
}

The Entropy trait specifies an object that has a closed form solution for its entropy

Required methods

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

Returns the entropy. May panic depending on the implementor.

Examples

use statrs::statistics::Entropy;
use statrs::distribution::Uniform;

let n = Uniform::new(0.0, 1.0).unwrap();
assert_eq!(0.0, n.entropy());
Loading content...

Implementors

impl Entropy<f64> for Bernoulli[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the bernoulli distribution

Formula

q = (1 - p)
-q * ln(q) - p * ln(p)

impl Entropy<f64> for Beta[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the beta distribution

Formula

ln(B(α, β)) - (α - 1)ψ(α) - (β - 1)ψ(β) + (α + β - 2)ψ(α + β)

where α is shapeA, β is shapeB and ψ is the digamma function

impl Entropy<f64> for Binomial[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the binomial distribution

Formula

(1 / 2) * ln (2 * π * e * n * p * (1 - p))

impl Entropy<f64> for Categorical[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the categorical distribution

Formula

-Σ(p_j * ln(p_j))

where p_j is the jth probability mass, Σ is the sum from 0 to k - 1, and k is the number of categories

impl Entropy<f64> for Cauchy[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the cauchy distribution

Formula

ln(γ) + ln()

where γ is the scale

impl Entropy<f64> for Chi[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the chi distribution

Remarks

Returns NaN if freedom is INF

Formula

ln(Γ(k / 2)) + 0.5 * (k - ln2 - (k - 1) * ψ(k / 2))

where k is degrees of freedom, Γ is the gamma function, and ψ is the digamma function

impl Entropy<f64> for ChiSquared[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the chi-squared distribution

Formula

(k / 2) + ln(2 * Γ(k / 2)) + (1 - (k / 2)) * ψ(k / 2)

where k is the degrees of freedom, Γ is the gamma function, and ψ is the digamma function

impl Entropy<f64> for Dirichlet[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the dirichlet distribution

Formula

ln(B(α)) - (K - α_0)ψ(α_0) - Σ((α_i - 1)ψ(α_i))

where

B(α) = Π(Γ(α_i)) / Γ(Σ(α_i))

α_0 is the sum of all concentration parameters, K is the number of concentration parameters, ψ is the digamma function, α_i is the ith concentration parameter, and Σ is the sum from 1 to K

impl Entropy<f64> for DiscreteUniform[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the discrete uniform distribution

Formula

ln(max - min + 1)

impl Entropy<f64> for Erlang[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the erlang distribution

Formula

k - ln(λ) + ln(Γ(k)) + (1 - k) * ψ(k)

where k is the shape, λ is the rate, Γ is the gamma function, and ψ is the digamma function

impl Entropy<f64> for Exponential[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the exponential distribution

Formula

1 - ln(λ)

where λ is the rate

impl Entropy<f64> for Gamma[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the gamma distribution

Formula

α - ln(β) + ln(Γ(α)) + (1 - α) * ψ(α)

where α is the shape, β is the rate, Γ is the gamma function, and ψ is the digamma function

impl Entropy<f64> for Geometric[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the geometric distribution

Formula

(-(1 - p) * log_2(1 - p) - p * log_2(p)) / p

impl Entropy<f64> for InverseGamma[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the inverse gamma distribution

Formula

α + ln(β * Γ(α)) - (1 + α) * ψ(α)

where α is the shape, β is the rate, Γ is the gamma function, and ψ is the digamma function

impl Entropy<f64> for LogNormal[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the log-normal distribution

Formula

ln(σe^(μ + 1 / 2) * sqrt())

where μ is the location and σ is the scale

impl Entropy<f64> for Normal[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the normal distribution

Formula

(1 / 2) * ln(^2 * π * e)

where σ is the standard deviation

impl Entropy<f64> for Pareto[src]

fn entropy(&self) -> f64[src]

Returns the entropy for the Pareto distribution

Formula

ln(α/x_m) - 1/α - 1

where x_m is the scale and α is the shape

impl Entropy<f64> for Poisson[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the poisson distribution

Formula

(1 / 2) * ln(2πeλ) - 1 / (12λ) - 1 / (24λ^2) - 19 / (360λ^3)

where λ is the rate

impl Entropy<f64> for StudentsT[src]

fn entropy(&self) -> f64[src]

Returns the entropy for the student’s t-distribution

Panics

If location != 0.0 && scale != 1.0

Formula

(v + 1) / 2 * (ψ((v + 1) / 2) - ψ(v / 2)) + ln(sqrt(v) * B(v / 2, 1 /
2))

where v is the freedom, ψ is the digamma function, and B is the beta function

impl Entropy<f64> for Triangular[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the triangular distribution

Formula

1 / 2 + ln((max - min) / 2)

impl Entropy<f64> for Uniform[src]

fn entropy(&self) -> f64[src]

Returns the entropy for the continuous uniform distribution

Formula

ln(max - min)

impl Entropy<f64> for Weibull[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the weibull distribution

Formula

γ(1 - 1 / k) + ln(λ / k) + 1

where k is the shape, λ is the scale, and γ is the Euler-Mascheroni constant

Loading content...