Learn R Programming

hint (version 0.1-0)

sim.hydist: Simulating the Drawing of Distinct Categories

Description

This function simulates the drawing of balls from a single urn containing q duplicates in n categories to generate distributions of the number of distinct categories drawn.

Usage

sim.hydist(n, a, sims = 10000, Na = rep(2, n))

Arguments

n
An integer specifying the number of categories in the urn.
a
An integer specifying the number of balls drawn from the urn.
sims
An integer specifying the number of replicate draws for the simulation. Defaults to 10,000.
Na
A vector of integers specifying the number of balls in each category of the urn.

Value

  • An integer vector of length sims giving the numbers of distinct categories for all replicates of the simulation.

Details

The simulation allows any number of balls in each of the n categories via the Na argument.

References

Kalinka, A.T. (2013). The probability of drawing intersections: extending the hypergeometric distribution. http://arxiv.org/abs/1305.0717{arXiv.1305.0717}

See Also

Hyperdistinct.

Examples

Run this code
## All n categories contain duplicates:
nn <- sim.hydist(108, 74, sims = 10)
## Duplicates in 78 of the categories:
nn <- sim.hydist(108, 74, sims = 10, Na = c(rep(1,(108-78)),rep(2,78)))

Run the code above in your browser using DataLab