Struct statrs::distribution::Hypergeometric [−][src]
pub struct Hypergeometric { /* fields omitted */ }
Implementations
impl Hypergeometric
[src]
impl Hypergeometric
[src]pub fn new(
population: u64,
successes: u64,
draws: u64
) -> Result<Hypergeometric>
[src]
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());
pub fn population(&self) -> u64
[src]
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);
pub fn successes(&self) -> u64
[src]
Returns the number of observed successes of the hypergeometric distribution
Examples
use statrs::distribution::Hypergeometric; let n = Hypergeometric::new(10, 5, 3).unwrap(); assert_eq!(n.successes(), 5);
pub fn draws(&self) -> u64
[src]
Returns the number of draws of the hypergeometric distribution
Examples
use statrs::distribution::Hypergeometric; let n = Hypergeometric::new(10, 5, 3).unwrap(); assert_eq!(n.draws(), 3);
Trait Implementations
impl CheckedMean<f64> for Hypergeometric
[src]
impl CheckedMean<f64> for Hypergeometric
[src]impl CheckedSkewness<f64> for Hypergeometric
[src]
impl CheckedSkewness<f64> for Hypergeometric
[src]impl CheckedVariance<f64> for Hypergeometric
[src]
impl CheckedVariance<f64> for Hypergeometric
[src]fn checked_variance(&self) -> Result<f64>
[src]
Returns the variance of the hypergeometric distribution
Errors
If N <= 1
Formula
n * (K / N) * ((N - K) / N) * ((N - n) / (N - 1))
where N
is population, K
is successes, and n
is draws
fn checked_std_dev(&self) -> Result<f64>
[src]
impl Clone for Hypergeometric
[src]
impl Clone for Hypergeometric
[src]fn clone(&self) -> Hypergeometric
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Discrete<u64, f64> for Hypergeometric
[src]
impl Discrete<u64, f64> for Hypergeometric
[src]fn pmf(&self, x: u64) -> f64
[src]
Calculates the probability mass function for the hypergeometric
distribution at x
Formula
(K choose x) * (N-K choose n-x) / (N choose n)
where N
is population, K
is successes, and n
is draws
fn ln_pmf(&self, x: u64) -> f64
[src]
Calculates the log probability mass function for the hypergeometric
distribution at x
Formula
ln((K choose x) * (N-K choose n-x) / (N choose n))
where N
is population, K
is successes, and n
is draws
impl Distribution<f64> for Hypergeometric
[src]
impl Distribution<f64> for Hypergeometric
[src]impl Max<u64> for Hypergeometric
[src]
impl Max<u64> for Hypergeometric
[src]impl Mean<f64> for Hypergeometric
[src]
impl Mean<f64> for Hypergeometric
[src]impl Min<u64> for Hypergeometric
[src]
impl Min<u64> for Hypergeometric
[src]impl Mode<u64> for Hypergeometric
[src]
impl Mode<u64> for Hypergeometric
[src]impl PartialEq<Hypergeometric> for Hypergeometric
[src]
impl PartialEq<Hypergeometric> for Hypergeometric
[src]fn eq(&self, other: &Hypergeometric) -> bool
[src]
fn ne(&self, other: &Hypergeometric) -> bool
[src]
impl Skewness<f64> for Hypergeometric
[src]
impl Skewness<f64> for Hypergeometric
[src]impl Univariate<u64, f64> for Hypergeometric
[src]
impl Univariate<u64, f64> for Hypergeometric
[src]fn cdf(&self, x: f64) -> f64
[src]
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)
and p_F_q
is the [generalized hypergeometric
function](https://en.wikipedia.
org/wiki/Generalized_hypergeometric_function)
impl Variance<f64> for Hypergeometric
[src]
impl Variance<f64> for Hypergeometric
[src]