rAlias {MiscMath} | R Documentation |
Alias Method for Generating Discrete Random Variates
Description
Efficient method for generating discrete random variates from any distribution with a finite number (N) of states. The method is described in detail in Section 10.1 of the given reference.
Usage
rAlias(n, P)
Arguments
n |
numeric, constant number of variates to be simulated |
P |
numeric, probability mass function, assuming states from 1 through N |
Value
numeric vector of containing n simulated values from the given discrete distribution
References
S. Ross (1990) A Course in Simulation, MacMillan.
Examples
x <- rAlias(n = 100, P = c(1:5)/15)
table(x)/100
[Package MiscMath version 1.1 Index]