rmultihyper: The Multinomial Hypergeometric Distribution

Description Usage Arguments Details Value References See Also Examples

View source: R/multihyper.R

Description

Sample a fixed number of balls, without replacement, from multiple urns.

Usage

1

Arguments

n

a vector describing the number of balls in each urn

k

the total number of balls to draw from the urns

Details

Requesting a non-integer or negative number of balls, or more than are available in all the urns, will throw an error. If k is a vector of length > 1, only the first element will be used. Specifying only one or two urns will respectively return k or call stats::rhyper() and issue a warning.

If k = ∑ n then the function should return n.

Value

A vector or array corresponding to the number of balls sampled from each of the urns, in the same format as n.

References

http://stats.stackexchange.com/questions/199948/random-generation-from-multivariate-hypergeometric-distribution

See Also

stats::rhyper() for sampling two different colours of balls from a single urn (equivalent to sampling one colour from two urns)

Examples

1
2
3
4
5
rmultihyper(c(5, 10, 8), 6)

# 90% sample of citation counts data
k <- round(0.9 * sum(citations))
rmultihyper(citations, k)

Selbosh/scrooge documentation built on May 5, 2019, 8 p.m.