Struct ndarray_rand::rand_distr::Hypergeometric [−][src]
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 analagous 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
impl Hypergeometric
[src]
pub fn new(
total_population_size: u64,
population_with_feature: u64,
sample_size: u64
) -> Result<Hypergeometric, Error>
[src]
total_population_size: u64,
population_with_feature: u64,
sample_size: u64
) -> Result<Hypergeometric, Error>
Constructs a new Hypergeometric
with the shape parameters
N = total_population_size
,
K = population_with_feature
,
n = sample_size
.
Trait Implementations
impl Clone for Hypergeometric
[src]
pub fn clone(&self) -> Hypergeometric
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Hypergeometric
[src]
impl Debug for Hypergeometric
[src]
impl Distribution<u64> for Hypergeometric
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,