dhyper_rvec {rvec}R Documentation

The Hypergeometric Distribution, Using Multiple Draws

Description

Density, distribution function, quantile function and random generation for the hypergeometric distribution, modified to work with rvecs.

Usage

dhyper_rvec(x, m, n, k, log = FALSE)

phyper_rvec(q, m, n, k, lower.tail = TRUE, log.p = FALSE)

qhyper_rvec(p, m, n, k, lower.tail = TRUE, log.p = FALSE)

rhyper_rvec(nn, m, n, k, n_draw = NULL)

Arguments

x

Quantiles. Can be an rvec.

m

Number of white balls in the urn. See stats::dhyper(). Can be an rvec.

n

Number of black balls in the urn. See stats::rhyper(). Can be an rvec.

k

Number of balls drawn from urn. See stats::dhyper(). Can be an rvec.

log, log.p

Whether to return results on a log scale. Default is FALSE. Cannot be an rvec.

q

Quantiles. Can be an rvec.

lower.tail

Whether to return P[X \le x], as opposed to P[X > x]. Default is TRUE. Cannot be an rvec.

p

Probabilities. Can be an rvec.

nn

The length of the random vector being created. The equivalent of n in other random variate functions. See stats::rhyper(). Cannot be an rvec.

n_draw

Number of random draws in the random vector being created. Cannot be an rvec.

Details

Functions dhyper_rvec(), phyper_rvec(), phyper_rvec() and rhyper_rvec() work like base R functions dhyper(), phyper(), qhyper(), and rhyper(), except that they accept rvecs as inputs. If any input is an rvec, then the output will be too. Function rhyper_rvec() also returns an rvec if a value for n_draw is supplied.

dhyper_rvec(), phyper_rvec(), phyper_rvec() and rhyper_rvec() use tidyverse vector recycling rules:

Value

See Also

Examples

x <- rvec(list(c(3, 5),
               c(0, 2)))
dhyper_rvec(x, m = 6, n = 6, k = 5)
phyper_rvec(x, m = 6, n = 6, k = 5)

rhyper_rvec(nn = 2,
            k = c(3, 5),
            m = 6,
            n = 6,
            n_draw = 1000)

[Package rvec version 0.0.6 Index]