Struct rand::distributions::ChiSquared
source · [−]pub struct ChiSquared { /* 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::distributions::{ChiSquared, Distribution};
let chi = ChiSquared::new(11.0);
let v = chi.sample(&mut rand::thread_rng());
println!("{} is from a χ²(11) distribution", v)
Implementations
sourceimpl ChiSquared
impl ChiSquared
sourcepub fn new(k: f64) -> ChiSquared
pub fn new(k: f64) -> ChiSquared
Create a new chi-squared distribution with degrees-of-freedom
k
. Panics if k < 0
.
Trait Implementations
sourceimpl Clone for ChiSquared
impl Clone for ChiSquared
sourcefn clone(&self) -> ChiSquared
fn clone(&self) -> ChiSquared
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 Debug for ChiSquared
impl Debug for ChiSquared
sourceimpl Distribution<f64> for ChiSquared
impl Distribution<f64> for ChiSquared
sourcefn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64
Generate a random value of T
, using rng
as the source of randomness.
sourcefn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T>ⓘNotable traits for DistIter<'a, D, R, T>impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> where
D: Distribution<T>,
R: Rng + 'a, type Item = T;
where
Self: Sized,
R: Rng,
fn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T>ⓘNotable traits for DistIter<'a, D, R, T>impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> where
D: Distribution<T>,
R: Rng + 'a, type Item = T;
where
Self: Sized,
R: Rng,
D: Distribution<T>,
R: Rng + 'a, type Item = T;
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
impl Copy for ChiSquared
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more