rmvhyper {osDesign}R Documentation

Random generation for the multivariate hypergeometric distribution

Description

Generates a single random deviate from a multivariate hypergeometric distribution.

Usage

rmvhyper(Mk, m)

Arguments

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

Details

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.

Value

A numeric vector of elements, totally to m, drawn without replacement from the population described by Mk.

Author(s)

Sebastien Haneuse

See Also

rhyper.

Examples

##
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))

[Package osDesign version 1.8 Index]