The Hypergeometric Distribution

Usage

dhyper(x, m, n, k)
phyper(q, m, n, k)
qhyper(p, m, n, k)
rhyper(nn, m, n, k)

Arguments

x,q vector of quantiles representing the number of white balls drawn without replacement from an urn which contains both black and white balls.
m the number of white balls in the urn.
n the number of black balls in the urn.
k the number of balls drawn from the urn.
p probability, it must be between 0 and 1.
nn the number of observations to be generated.

Details

For large values of k,

Value

These functions provide information about the hypergeometric distribution with parameters m, n and k (named Np, N-Np, and n, respectively in the reference below). dhyper gives the density, phyper gives the distribution function qhyper gives the quantile function and rhyper generates random deviates.

The hypergeometric distribution is used for sampling without replacement. It has density

p(x) = choose(m, x) choose(n, k-x) / choose(m+n, k)

for x = 0, ..., k.

References

Johnson, N.L., Kotz, S. and Kemp, A.W. (1992). Univariate Discrete Distributions, 2nd Ed., Wiley.

Examples

m <- 10; n <- 7; k <- 8
x <- 0:m
rbind(phyper(x, m, n, k), dhyper(x, m, n, k))
all(phyper(x, m, n, k) == cumsum(dhyper(x, m, n, k)))# FALSE
## Error :
signif(phyper(x, m, n, k) - cumsum(dhyper(x, m, n, k)), dig=3)


[Package Contents]