Struct sprs_rand::rand_distr::ChiSquared
source · [−]pub struct ChiSquared<N> { /* private fields */ }
Expand description
The chi-squared distribution χ²(k)
, where k
is the degrees of
freedom.
For k > 0
integral, this distribution is the sum of the squares
of k
independent standard normal random variables. For other
k
, this uses the equivalent characterisation
χ²(k) = Gamma(k/2, 2)
.
Example
use rand_distr::{ChiSquared, Distribution};
let chi = ChiSquared::new(11.0).unwrap();
let v = chi.sample(&mut rand::thread_rng());
println!("{} is from a χ²(11) distribution", v)
Implementations
sourceimpl<N> ChiSquared<N> where
N: Float,
StandardNormal: Distribution<N>,
Exp1: Distribution<N>,
Open01: Distribution<N>,
impl<N> ChiSquared<N> where
N: Float,
StandardNormal: Distribution<N>,
Exp1: Distribution<N>,
Open01: Distribution<N>,
sourcepub fn new(k: N) -> Result<ChiSquared<N>, ChiSquaredError>
pub fn new(k: N) -> Result<ChiSquared<N>, ChiSquaredError>
Create a new chi-squared distribution with degrees-of-freedom
k
.
Trait Implementations
sourceimpl<N> Clone for ChiSquared<N> where
N: Clone,
impl<N> Clone for ChiSquared<N> where
N: Clone,
sourcefn clone(&self) -> ChiSquared<N>
fn clone(&self) -> ChiSquared<N>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<N> Debug for ChiSquared<N> where
N: Debug,
impl<N> Debug for ChiSquared<N> where
N: Debug,
sourceimpl<N> Distribution<N> for ChiSquared<N> where
N: Float,
StandardNormal: Distribution<N>,
Exp1: Distribution<N>,
Open01: Distribution<N>,
impl<N> Distribution<N> for ChiSquared<N> where
N: Float,
StandardNormal: Distribution<N>,
Exp1: Distribution<N>,
Open01: Distribution<N>,
sourcefn sample<R>(&self, rng: &mut R) -> N where
R: Rng + ?Sized,
fn sample<R>(&self, rng: &mut R) -> N where
R: Rng + ?Sized,
Generate a random value of T
, using rng
as the source of randomness.
sourcefn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘNotable traits for DistIter<D, R, T>impl<D, R, T> Iterator for DistIter<D, R, T> where
D: Distribution<T>,
R: Rng, type Item = T;
where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘNotable traits for DistIter<D, R, T>impl<D, R, T> Iterator for DistIter<D, R, T> where
D: Distribution<T>,
R: Rng, type Item = T;
where
R: Rng,
D: Distribution<T>,
R: Rng, type Item = T;
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
impl<N> Copy for ChiSquared<N> where
N: Copy,
Auto Trait Implementations
impl<N> RefUnwindSafe for ChiSquared<N> where
N: RefUnwindSafe,
impl<N> Send for ChiSquared<N> where
N: Send,
impl<N> Sync for ChiSquared<N> where
N: Sync,
impl<N> Unpin for ChiSquared<N> where
N: Unpin,
impl<N> UnwindSafe for ChiSquared<N> where
N: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.