dau.new: UNU.RAN generator based on the Alias method (DAU)
Description
UNU.RAN random variate generator for discrete distributions with given
probability vector.
It applies the Alias-Urn method (DAU).
[Universal] -- Patchwork Method.
Usage
dau.new(pv, from=1)
Arguments
pv
vector of non-negative numbers (need not sum to 1). (numeric vector)
from
index of first entry in vector. (integer)
Details
This function creates a unuran object based on DAU
(Discrete Alias-Urn method). It can be used to draw samples of a
discrete random variate with given probability vector
using ur.
The probabilities must be provided by a vector pv which must
contain non-negative numbers and which need not necessarily sum up to
1.
The method runs fast in constant time, i.e., marginal sampling
times do not depend on the length of the given probability vector.
Whereas their setup times grow linearly with this length.
Notice that the range of random variates is
from:(from+length(pv)-1).
References
W. H"ormann, J. Leydold, and G. Derflinger (2004):
Automatic Nonuniform Random Variate Generation.
Springer-Verlag, Berlin Heidelberg.
See Section 3.2 (The Alias Method).
A.J. Walker (1977):
An efficient method for generating discrete random variables with
general distributions.
ACM Trans. Model. Comput. Simul. 3, pp.253--256.