Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/rmhyper.q View source: R/rmhyper.q
Generates a single random deviate from a multivariate hypergeometric distribution.
1 | rmvhyper(Mk, m)
|
Mk |
A numeric vector describing the population from which the sub-sample will be drawn. |
m |
Number of elements to be drawn from the population |
The multivariate hypergeometric distribution is for sampling without replacement from a population with a finite number of element types. The number of element types is given by the length of the vector Mk
.
A numeric vector of elements, totally to m
, drawn without replacement from the population described by Mk
.
Sebastien Haneuse
1 2 3 4 5 6 7 8 9 10 11 12 13 | ##
rmvhyper(c(1000, 500, 200, 50), 200)
## Check the properties (first two moments) of the generated deviates
##
M <- 100
Qx <- c(0.7, 0.15, 0.1, 0.05)
temp <- matrix(NA, nrow=10000, ncol=length(Qx))
for(i in 1:nrow(temp)) temp[i,] <- rmvhyper(M*Qx, 1)
##
rbind(Qx, apply(temp, 2, mean))
rbind(sqrt(Qx * (1-Qx)), apply(temp, 2, sd))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.