Struct statrs::distribution::Hypergeometric
source · pub struct Hypergeometric { /* private fields */ }
Expand description
Implementations§
source§impl 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§
source§impl Clone for Hypergeometric
impl Clone for Hypergeometric
source§fn clone(&self) -> Hypergeometric
fn clone(&self) -> Hypergeometric
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Hypergeometric
impl Debug for Hypergeometric
source§impl DiscreteCDF<u64, f64> for Hypergeometric
impl DiscreteCDF<u64, f64> for Hypergeometric
source§fn 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)
source§fn 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.
source§impl Distribution<f64> for Hypergeometric
impl Distribution<f64> for Hypergeometric
source§fn 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.source§impl Distribution<f64> for Hypergeometric
impl Distribution<f64> for Hypergeometric
source§impl Max<u64> for Hypergeometric
impl Max<u64> for Hypergeometric
source§impl Min<u64> for Hypergeometric
impl Min<u64> for Hypergeometric
source§impl PartialEq<Hypergeometric> for Hypergeometric
impl PartialEq<Hypergeometric> for Hypergeometric
source§fn 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 ==
.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§
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
Mutably borrows from an owned value. Read more
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>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moresource§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).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.