Struct statrs::distribution::Hypergeometric
source · [−]pub struct Hypergeometric { /* private fields */ }
Expand description
Implementations
sourceimpl Hypergeometric
impl Hypergeometric
sourcepub fn new(
population: u64,
successes: u64,
draws: u64
) -> Result<Hypergeometric>
pub fn new(
population: u64,
successes: u64,
draws: u64
) -> Result<Hypergeometric>
Constructs a new hypergeometric distribution
with a population (N) of population
, number
of successes (K) of successes
, and number of draws
(n) of draws
Errors
If successes > population
or draws > population
Examples
use statrs::distribution::Hypergeometric;
let mut result = Hypergeometric::new(2, 2, 2);
assert!(result.is_ok());
result = Hypergeometric::new(2, 3, 2);
assert!(result.is_err());
sourcepub fn population(&self) -> u64
pub fn population(&self) -> u64
Returns the population size of the hypergeometric distribution
Examples
use statrs::distribution::Hypergeometric;
let n = Hypergeometric::new(10, 5, 3).unwrap();
assert_eq!(n.population(), 10);
Trait Implementations
sourceimpl Clone for Hypergeometric
impl Clone for Hypergeometric
sourcefn clone(&self) -> Hypergeometric
fn clone(&self) -> Hypergeometric
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 Hypergeometric
impl Debug for Hypergeometric
sourceimpl Discrete<u64, f64> for Hypergeometric
impl Discrete<u64, f64> for Hypergeometric
sourceimpl DiscreteCDF<u64, f64> for Hypergeometric
impl DiscreteCDF<u64, f64> for Hypergeometric
sourcefn cdf(&self, x: u64) -> f64
fn cdf(&self, x: u64) -> f64
Calculates the cumulative distribution function for the hypergeometric
distribution at x
Formula
1 - ((n choose k+1) * (N-n choose K-k-1)) / (N choose K) * 3_F_2(1,
k+1-K, k+1-n; k+2, N+k+2-K-n; 1)
where N
is population, K
is successes, n
is draws,
and p_F_q
is the [generalized hypergeometric
function](https://en.wikipedia.
org/wiki/Generalized_hypergeometric_function)
sourcefn inverse_cdf(&self, p: T) -> K
fn inverse_cdf(&self, p: T) -> K
Due to issues with rounding and floating-point accuracy the default implementation may be ill-behaved Specialized inverse cdfs should be used whenever possible. Read more
sourceimpl Distribution<f64> for Hypergeometric
impl Distribution<f64> for Hypergeometric
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<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
sourceimpl Distribution<f64> for Hypergeometric
impl Distribution<f64> for Hypergeometric
sourceimpl Max<u64> for Hypergeometric
impl Max<u64> for Hypergeometric
sourceimpl Min<u64> for Hypergeometric
impl Min<u64> for Hypergeometric
sourceimpl Mode<Option<u64>> for Hypergeometric
impl Mode<Option<u64>> for Hypergeometric
sourceimpl PartialEq<Hypergeometric> for Hypergeometric
impl PartialEq<Hypergeometric> for Hypergeometric
sourcefn eq(&self, other: &Hypergeometric) -> bool
fn eq(&self, other: &Hypergeometric) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Hypergeometric) -> bool
fn ne(&self, other: &Hypergeometric) -> bool
This method tests for !=
.
impl Copy for Hypergeometric
impl StructuralPartialEq for Hypergeometric
Auto Trait Implementations
impl RefUnwindSafe for Hypergeometric
impl Send for Hypergeometric
impl Sync for Hypergeometric
impl Unpin for Hypergeometric
impl UnwindSafe for Hypergeometric
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<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
sourcepub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
sourcepub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
sourcepub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
sourcepub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
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