# [−][src]Struct statrs::distribution::Hypergeometric

## Methods

`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 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 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 Min<u64> for Hypergeometric`

[src]

`fn min(&self) -> u64`

[src]

Returns the minimum value in the domain of the hypergeometric distribution representable by a 64-bit integer

# Formula

max(0, n + K - N)

where `N`

is population, `K`

is successes, and `n`

is draws

`impl Max<u64> for Hypergeometric`

[src]

`fn max(&self) -> u64`

[src]

Returns the maximum value in the domain of the hypergeometric distribution representable by a 64-bit integer

# Formula

min(K, n)

where `K`

is successes and `n`

is draws

`impl Mean<f64> for Hypergeometric`

[src]

`impl CheckedMean<f64> for Hypergeometric`

[src]

`fn checked_mean(&self) -> Result<f64>`

[src]

`impl Variance<f64> for Hypergeometric`

[src]

`fn variance(&self) -> f64`

[src]

Returns the variance of the hypergeometric distribution

# Panics

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 std_dev(&self) -> f64`

[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 Skewness<f64> for Hypergeometric`

[src]

`impl CheckedSkewness<f64> for Hypergeometric`

[src]

`fn checked_skewness(&self) -> Result<f64>`

[src]

`impl Mode<u64> for Hypergeometric`

[src]

`fn mode(&self) -> u64`

[src]

Returns the mode of the hypergeometric distribution

# Formula

floor((n + 1) * (k + 1) / (N + 2))

where `N`

is population, `K`

is successes, and `n`

is draws

`impl Copy for Hypergeometric`

[src]

`impl PartialEq<Hypergeometric> for Hypergeometric`

[src]

`fn eq(&self, other: &Hypergeometric) -> bool`

[src]

`fn ne(&self, other: &Hypergeometric) -> bool`

[src]

`impl Clone for Hypergeometric`

[src]

`fn clone(&self) -> Hypergeometric`

[src]

`fn clone_from(&mut self, source: &Self)`

1.0.0[src]

Performs copy-assignment from `source`

. Read more

`impl Debug for Hypergeometric`

[src]

`impl Distribution<f64> for Hypergeometric`

[src]

## Auto Trait Implementations

`impl Send for Hypergeometric`

`impl Sync for Hypergeometric`

## Blanket Implementations

`impl<T> ToOwned for T where`

T: Clone,

[src]

T: Clone,

`type Owned = T`

The resulting type after obtaining ownership.

`fn to_owned(&self) -> T`

[src]

`fn clone_into(&self, target: &mut T)`

[src]

`impl<T> From<T> for T`

[src]

`impl<T, U> Into<U> for T where`

U: From<T>,

[src]

U: From<T>,

`impl<T, U> TryFrom<U> for T where`

U: Into<T>,

[src]

U: Into<T>,

`type Error = Infallible`

The type returned in the event of a conversion error.

`fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`

[src]

`impl<T, U> TryInto<U> for T where`

U: TryFrom<T>,

[src]

U: TryFrom<T>,

`type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

`fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`

[src]

`impl<T> BorrowMut<T> for T where`

T: ?Sized,

[src]

T: ?Sized,

`fn borrow_mut(&mut self) -> &mut T`

[src]

`impl<T> Borrow<T> for T where`

T: ?Sized,

[src]

T: ?Sized,

`impl<T> Any for T where`

T: 'static + ?Sized,

[src]

T: 'static + ?Sized,