Last chance! 50% off unlimited learning
Sale ends in
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)
length(nn) > 1
, the length
is taken to be the number required.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. The length of the result is determined by n
for
rhyper
, and is the maximum of the lengths of the
numerical arguments for the other functions. The numerical arguments other than n
are recycled to the
length of the result. Only the first elements of the logical
arguments are used.m
, n
and k
(named .Machine$integer.max
,
currently the equivalent of qhyper(runif(nn), m,n,k)
is used,
when a binomial approximation may be considerably more efficient.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)
Run the code above in your browser using DataLab