Struct statrs::distribution::ChiSquared [−][src]
Implements the Chi-squared distribution which is a special case of the Gamma distribution (referenced Here)
Examples
use statrs::distribution::{ChiSquared, Continuous}; use statrs::statistics::Mean; use statrs::prec; let n = ChiSquared::new(3.0).unwrap(); assert_eq!(n.mean(), 3.0); assert!(prec::almost_eq(n.pdf(4.0), 0.107981933026376103901, 1e-15));
Implementations
impl ChiSquared
[src]
pub fn new(freedom: f64) -> Result<ChiSquared>
[src]
Constructs a new chi-squared distribution with freedom
degrees of freedom. This is equivalent to a Gamma distribution
with a shape of freedom / 2.0
and a rate of 0.5
.
Errors
Returns an error if freedom
is NaN
or less than
or equal to 0.0
Examples
use statrs::distribution::ChiSquared; let mut result = ChiSquared::new(3.0); assert!(result.is_ok()); result = ChiSquared::new(0.0); assert!(result.is_err());
pub fn freedom(&self) -> f64
[src]
Returns the degrees of freedom of the chi-squared distribution
Examples
use statrs::distribution::ChiSquared; let n = ChiSquared::new(3.0).unwrap(); assert_eq!(n.freedom(), 3.0);
pub fn shape(&self) -> f64
[src]
Returns the shape of the underlying Gamma distribution
Examples
use statrs::distribution::ChiSquared; let n = ChiSquared::new(3.0).unwrap(); assert_eq!(n.shape(), 3.0 / 2.0);
pub fn rate(&self) -> f64
[src]
Returns the rate of the underlying Gamma distribution
Examples
use statrs::distribution::ChiSquared; let n = ChiSquared::new(3.0).unwrap(); assert_eq!(n.rate(), 0.5);
Trait Implementations
impl Clone for ChiSquared
[src]
fn clone(&self) -> ChiSquared
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Continuous<f64, f64> for ChiSquared
[src]
fn pdf(&self, x: f64) -> f64
[src]
Calculates the probability density function for the chi-squared
distribution at x
Formula
1 / (2^(k / 2) * Γ(k / 2)) * x^((k / 2) - 1) * e^(-x / 2)
where k
is the degrees of freedom and Γ
is the gamma function
fn ln_pdf(&self, x: f64) -> f64
[src]
Calculates the log probability density function for the chi-squared
distribution at x
Formula
ln(1 / (2^(k / 2) * Γ(k / 2)) * x^((k / 2) - 1) * e^(-x / 2))
impl Copy for ChiSquared
[src]
impl Debug for ChiSquared
[src]
impl Distribution<f64> for ChiSquared
[src]
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64
[src]
pub fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
[src]
R: Rng,
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 Max<f64> for ChiSquared
[src]
fn max(&self) -> f64
[src]
Returns the maximum value in the domain of the chi-squared distribution representable by a double precision float
Formula
INF
impl Mean<f64> for ChiSquared
[src]
impl Median<f64> for ChiSquared
[src]
impl Min<f64> for ChiSquared
[src]
fn min(&self) -> f64
[src]
Returns the minimum value in the domain of the chi-squared distribution representable by a double precision float
Formula
0
impl Mode<f64> for ChiSquared
[src]
impl PartialEq<ChiSquared> for ChiSquared
[src]
fn eq(&self, other: &ChiSquared) -> bool
[src]
fn ne(&self, other: &ChiSquared) -> bool
[src]
impl Skewness<f64> for ChiSquared
[src]
fn skewness(&self) -> f64
[src]
Returns the skewness of the chi-squared distribution
Formula
sqrt(8 / k)
where k
is the degrees of freedom
impl StructuralPartialEq for ChiSquared
[src]
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 Variance<f64> for ChiSquared
[src]
Auto Trait Implementations
impl RefUnwindSafe for ChiSquared
impl Send for ChiSquared
impl Sync for ChiSquared
impl Unpin for ChiSquared
impl UnwindSafe for ChiSquared
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,