pub struct ChiSquared { /* private fields */ }
Expand description
Chi-Squared distribution: X ~ ChiSq(k)
Implementations§
Source§impl ChiSquared
impl ChiSquared
Trait Implementations§
Source§impl Default for ChiSquared
impl Default for ChiSquared
Source§fn default() -> ChiSquared
fn default() -> ChiSquared
Source§impl Distribution for ChiSquared
impl Distribution for ChiSquared
Source§fn cf(&self, t: f64) -> Complex<f64>
fn cf(&self, t: f64) -> Complex<f64>
Characteristic function of the Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(1);
let cf = chi.cf(1.0);
assert_approx_equal!(cf.re, 0.5688645, 1e-7);
assert_approx_equal!(cf.im, 0.3515776, 1e-7);
Source§fn pdf(&self, x: f64) -> f64
fn pdf(&self, x: f64) -> f64
Probability density function of the Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(1);
assert_approx_equal!(chi.pdf(1.0), 0.2419707, 1e-7);
Source§fn pmf(&self, x: f64) -> f64
fn pmf(&self, x: f64) -> f64
Probability mass function of the Chi-Squared distribution.
Using this method will call self.pdf(x)
instead
§Examples
let chi = ChiSquared::new(1);
assert_approx_equal!(chi.pmf(1.0), 0.2419707, 1e-7);
assert_approx_equal!(chi.pmf(1.0), chi.pdf(1.0), 1e-7);
Source§fn cdf(&self, x: f64) -> f64
fn cdf(&self, x: f64) -> f64
Cumulative distribution function of the Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(1);
assert_approx_equal!(chi.cdf(1.0), 0.6826895, 1e-7);
Source§fn inv_cdf(&self, p: f64) -> f64
fn inv_cdf(&self, p: f64) -> f64
Inverse (quantile) distribution function of the Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(1);
assert_approx_equal!(chi.inv_cdf(0.6826895), 1.0, 1e-7);
Source§fn mean(&self) -> f64
fn mean(&self) -> f64
Mean of the Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(1);
assert_eq!(chi.mean(), 1.0);
Source§fn median(&self) -> f64
fn median(&self) -> f64
Median of the Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(1);
assert_approx_equal!(chi.median(), 0.4705075, 1e-7);
Source§fn mode(&self) -> f64
fn mode(&self) -> f64
Mode of the Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(1);
assert_eq!(chi.mode(), 0.0);
Source§fn variance(&self) -> f64
fn variance(&self) -> f64
Variance of the Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(1);
assert_eq!(chi.variance(), 2.0);
Source§fn skewness(&self) -> f64
fn skewness(&self) -> f64
Skewness of the Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(1);
assert_approx_equal!(chi.skewness(), 2.8284271, 1e-7);
Source§fn kurtosis(&self) -> f64
fn kurtosis(&self) -> f64
Kurtosis of the Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(1);
assert_eq!(chi.kurtosis(), 12.0);
Source§fn entropy(&self) -> f64
fn entropy(&self) -> f64
Entropy of the Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(1);
assert_approx_equal!(chi.entropy(), 0.7837571, 1e-7);
Source§fn mgf(&self, t: f64) -> f64
fn mgf(&self, t: f64) -> f64
Moment-generating function of the Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(1);
assert_approx_equal!(chi.mgf(0.25), 1.4142135, 1e-7);
Source§fn sample(&self, n: usize) -> Result<Vec<f64>, RustQuantError>
fn sample(&self, n: usize) -> Result<Vec<f64>, RustQuantError>
Generates a random sample from a Chi-Squared distribution.
§Examples
let chi = ChiSquared::new(100);
let sample = chi.sample(100).expect("Error generating Chi-Squared sample.");
let mean = sample.iter().sum::<f64>() / sample.len() as f64;
assert_approx_equal!(mean, chi.mean(), 5.0);
Auto Trait Implementations§
impl Freeze for ChiSquared
impl RefUnwindSafe for ChiSquared
impl Send for ChiSquared
impl Sync for ChiSquared
impl Unpin for ChiSquared
impl UnwindSafe for ChiSquared
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.