Struct statrs::distribution::Chi [] [src]

pub struct Chi { /* fields omitted */ }

Implements the Chi distribution

Examples

use statrs::distribution::{Chi, Continuous};
use statrs::statistics::Mean;
use statrs::prec;

let n = Chi::new(2.0).unwrap();
assert!(prec::almost_eq(n.mean(), 1.25331413731550025121, 1e-14));
assert!(prec::almost_eq(n.pdf(1.0), 0.60653065971263342360, 1e-15));

Methods

impl Chi
[src]

Constructs a new chi distribution with freedom degrees of freedom

Errors

Returns an error if freedom is NaN or less than or equal to 0.0

Examples

use statrs::distribution::Chi;

let mut result = Chi::new(2.0);
assert!(result.is_ok());

result = Chi::new(0.0);
assert!(result.is_err());

Returns the degrees of freedom of the chi distribution.

Examples

use statrs::distribution::Chi;

let n = Chi::new(2.0).unwrap();
assert_eq!(n.freedom(), 2.0);

Trait Implementations

impl Debug for Chi
[src]

Formats the value using the given formatter.

impl Copy for Chi
[src]

impl Clone for Chi
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Chi
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Sample<f64> for Chi
[src]

Generate a random sample from a chi distribution using r as the source of randomness. Refer here for implementation details

impl IndependentSample<f64> for Chi
[src]

Generate a random independent sample from a chi distribution using r as the source of randomness. Refer here for implementation details

impl Distribution<f64> for Chi
[src]

Generate a random sample from the chi distribution using r as the source of randomness

Examples

use rand::StdRng;
use statrs::distribution::{Chi, Distribution};

let mut r = rand::StdRng::new().unwrap();
let n = Chi::new(2.0).unwrap();
print!("{}", n.sample::<StdRng>(&mut r));

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

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

Panics

If x < 0.0

Formula

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

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

impl Min<f64> for Chi
[src]

Returns the minimum value in the domain of the chi distribution representable by a double precision float

Formula

0

impl Max<f64> for Chi
[src]

Returns the maximum value in the domain of the chi distribution representable by a double precision float

Formula

INF

impl Mean<f64> for Chi
[src]

Returns the mean of the chi distribution

Formula

sqrt2 * Γ((k + 1) / 2) / Γ(k / 2)

where k is degrees of freedom and Γ is the gamma function

impl Variance<f64> for Chi
[src]

Returns the variance of the chi distribution

Formula

k - μ^2

where k is degrees of freedom and μ is the mean of the distribution

Returns the standard deviation of the chi distribution

Formula

sqrt(k - μ^2)

where k is degrees of freedom and μ is the mean of the distribution

impl Entropy<f64> for Chi
[src]

Returns the entropy of the chi distribution

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 Skewness<f64> for Chi
[src]

Returns the skewness of the chi distribution

Formula

(μ / σ^3) * (1 - ^2)

where μ is the mean and σ the standard deviation of the distribution

impl Mode<f64> for Chi
[src]

Returns the mode for the chi distribution

Panics

If freedom < 0.0

Formula

sqrt(k - 1)

where k is the degrees of freedom

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

Calculates the probability density function for the chi distribution at x

Panics

If x < 0.0

Formula

(2^(1 - (k / 2)) * x^(k - 1) * e^(-x^2 / 2)) / Γ(k / 2)

where k is the degrees of freedom and Γ is the gamma function

Calculates the log probability density function for the chi distribution at x

Panics

If x < 0.0

Formula

ln((2^(1 - (k / 2)) * x^(k - 1) * e^(-x^2 / 2)) / Γ(k / 2))