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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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)
Calculated as a discrete integral over the probability mass function evaluated from 0..k+1
Source§fn sf(&self, x: u64) -> f64
fn sf(&self, x: u64) -> f64
Calculates the survival 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)
Calculated as a discrete integral over the probability mass function evaluated from (k+1)..max
Source§fn inverse_cdf(&self, p: T) -> K
fn inverse_cdf(&self, p: T) -> K
Source§impl Distribution<f64> for Hypergeometric
impl Distribution<f64> for Hypergeometric
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 for Hypergeometric
impl PartialEq for Hypergeometric
impl Copy for Hypergeometric
impl StructuralPartialEq for Hypergeometric
Auto Trait Implementations§
impl Freeze for Hypergeometric
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.