Hypergeometric             package:stats             R Documentation

_T_h_e _H_y_p_e_r_g_e_o_m_e_t_r_i_c _D_i_s_t_r_i_b_u_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Density, distribution function, quantile function and random
     generation for the hypergeometric distribution.

_U_s_a_g_e:

     dhyper(x, m, n, k, log = FALSE)
     phyper(q, m, n, k, lower.tail = TRUE, log.p = FALSE)
     qhyper(p, m, n, k, lower.tail = TRUE, log.p = FALSE)
     rhyper(nn, m, n, k)

_A_r_g_u_m_e_n_t_s:

    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: number of observations. If 'length(nn) > 1', the length is
          taken to be the number required.

log, log.p: logical; if TRUE, probabilities p are given as log(p).

lower.tail: logical; if TRUE (default), probabilities are P[X <= x],
          otherwise, P[X > x].

_D_e_t_a_i_l_s:

     The hypergeometric distribution is used for sampling _without_
     replacement.  The density of this distribution with parameters
     'm', 'n' and 'k' (named Np, N-Np, and n, respectively in the
     reference below) is given by

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

     for x = 0, ..., k.

_V_a_l_u_e:

     'dhyper' gives the density, 'phyper' gives the distribution
     function, 'qhyper' gives the quantile function, and 'rhyper'
     generates random deviates.

     Invalid arguments will result in return value 'NaN', with a
     warning.

_S_o_u_r_c_e:

     'dhyper' computes via binomial probabilities, using code
     contributed by Catherine Loader (see 'dbinom').

     'phyper' is based on calculating 'dhyper' and
     'phyper(...)/dhyper(...)' (as a summation), based on ideas of Ian
     Smith and Morten Welinder.

     'qhyper' is based on inversion.

     'rhyper' is based on a corrected version of

     Kachitvichyanukul, V. and Schmeiser, B. (1985). Computer
     generation of hypergeometric random variates. _Journal of
     Statistical Computation and Simulation_, *22*, 127-145.

_R_e_f_e_r_e_n_c_e_s:

     Johnson, N. L., Kotz, S., and Kemp, A. W. (1992) _Univariate
     Discrete Distributions_, Second Edition. New York: Wiley.

_E_x_a_m_p_l_e_s:

     m <- 10; n <- 7; k <- 8
     x <- 0:(k+1)
     rbind(phyper(x, m, n, k), dhyper(x, m, n, k))
     all(phyper(x, m, n, k) == cumsum(dhyper(x, m, n, k)))# FALSE
     ## but error is very small:
     signif(phyper(x, m, n, k) - cumsum(dhyper(x, m, n, k)), digits=3)

