Skip to contents

Create a ddf object for the hypergeometric distribution with the given parameters.

Usage

hypergeometric(N, K, n)

Source

This function uses stats::dhyper() to calculate the distribution efficiently.

Arguments

N

A positive integer, the population size.

K

A non-negative integer, the number of success states in the population. Has to be less or equal to N.

n

A non-negative integer, the number of draws. Has to be less or equal to N.

Value

A ddf distribution as described above.

Details

The hypergeometric distribution models the number of successes when drawing \(n\) elements, without replacement, from a finite population of size \(N\) which contains \(K\) success states.

It has support $$\{\max(0, n+K-N), \dots, \min(n, K)\}$$ on which its probability mass function is given by $$p(k) = \frac{\binom{K}{k} \binom{N-K}{n-k}}{\binom{N}{n}}.$$

See also

Examples

# Model the total number of blue marbles when
# drawing 5 marbles from an urn containing
# 6 blue marbles and 20 marbles in total
hypergeometric(20, 6, 5)
#> Hypergeometric distribution with parameters N = 20, K = 6 and n = 5 
#> 
#> Support:
#> [1] 0 1 2 3 4 5
#> 
#> Probabilities:
#> [1] 0.1291279670 0.3873839009 0.3521671827 0.1173890609 0.0135448916
#> [6] 0.0003869969