\Header{Hypergeometric}{The Hypergeometric Distribution}
\alias{dhyper}{Hypergeometric}
\alias{phyper}{Hypergeometric}
\alias{qhyper}{Hypergeometric}
\alias{rhyper}{Hypergeometric}
\keyword{distribution}{Hypergeometric}
\begin{Usage}
\begin{verbatim}
dhyper(x, m, n, k)
phyper(q, m, n, k)
qhyper(p, m, n, k)
rhyper(nn, m, n, k)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{x,q}] vector of quantiles representing the number of white
balls drawn without replacement from an urn which contains both
black and white balls.
\item[\texttt{m}] the number of white balls in the urn.
\item[\texttt{n}] the number of black balls in the urn.
\item[\texttt{k}] the number of balls drawn from the urn.
\item[\texttt{p}] probability, it must be between 0 and 1.
\item[\texttt{nn}] the number of observations to be generated.
\end{ldescription}
\end{Arguments}
\begin{Details}
For large values of \texttt{k},\end{Details}
\begin{Value}
These functions provide information about the hypergeometric
distribution with parameters \texttt{m}, \texttt{n} and \texttt{k}
(named \eqn{Np}{}, \eqn{N-Np}{}, and \eqn{n}{}, respectively in
the reference below).
\texttt{dhyper} gives the density, \texttt{phyper} gives the distribution
function \texttt{qhyper} gives the quantile function and \texttt{rhyper}
generates random deviates.

The hypergeometric distribution is used for sampling \bold{without}
replacement.  It has density
\deqn{
p(x) = \left. {m \choose x}{n \choose k-x} \right/ {m+n \choose k}
}{p(x) =	choose(m, x) choose(n, k-x) / choose(m+n, k)}
for \eqn{x = 0, \ldots, k}{x = 0, ..., k}.\end{Value}
\begin{References}
Johnson, N.L., Kotz, S. and Kemp, A.W. (1992).
\emph{Univariate Discrete Distributions}, 2nd Ed., Wiley.\end{References}
\begin{Examples}
\begin{ExampleCode}
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)
\end{ExampleCode}
\end{Examples}

