# Struct rand_distr::Hypergeometric [−][src]

pub struct Hypergeometric { /* fields omitted */ }

## Expand description

The hypergeometric distribution `Hypergeometric(N, K, n)`

.

This is the distribution of successes in samples of size `n`

drawn without
replacement from a population of size `N`

containing `K`

success states.
It has the density function:
`f(k) = binomial(K, k) * binomial(N-K, n-k) / binomial(N, n)`

,
where `binomial(a, b) = a! / (b! * (a - b)!)`

.

The binomial distribution is the analogous distribution for sampling with replacement. It is a good approximation when the population size is much larger than the sample size.

# Example

use rand_distr::{Distribution, Hypergeometric}; let hypergeo = Hypergeometric::new(60, 24, 7).unwrap(); let v = hypergeo.sample(&mut rand::thread_rng()); println!("{} is from a hypergeometric distribution", v);

## Implementations

## Trait Implementations

Generate a random value of `T`

, using `rng`

as the source of randomness.

#### fn 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

## 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

Mutably borrows from an owned value. Read more