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]
fn new(freedom: f64) -> Result<Chi>
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());
fn freedom(&self) -> f64
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]
impl Copy for Chi
[src]
impl Clone for Chi
[src]
fn clone(&self) -> Chi
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Chi
[src]
fn eq(&self, __arg_0: &Chi) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Chi) -> bool
This method tests for !=
.
impl Sample<f64> for Chi
[src]
fn sample<R: Rng>(&mut self, r: &mut R) -> f64
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]
fn ind_sample<R: Rng>(&self, r: &mut R) -> f64
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]
fn sample<R: Rng>(&self, r: &mut R) -> f64
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]
impl Min<f64> for Chi
[src]
fn min(&self) -> f64
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]
fn max(&self) -> f64
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]
fn mean(&self) -> f64
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]
fn variance(&self) -> f64
Returns the variance of the chi distribution
Formula
k - μ^2
where k
is degrees of freedom and μ
is the mean
of the distribution
fn std_dev(&self) -> f64
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]
fn entropy(&self) -> f64
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]
fn skewness(&self) -> f64
Returns the skewness of the chi distribution
Formula
(μ / σ^3) * (1 - 2σ^2)
where μ
is the mean and σ
the standard deviation
of the distribution