UNU.RAN random variate generator for discrete distributions with given
probability vector.
It applies the Guide-Table Method (urdgt
) for discrete
inversion or the Alias-Urn Method (urdau
).
[ Deprecated.
Use dgt.new
or dau.new
instead. ]
urdgt(n, probvector, from = 0, by = 1)
urdau(n, probvector, from = 0, by = 1)
size of required sample.
vector of non-negative numbers (need not sum to 1).
number corresponding to the first probability in probvector.
"from + (k-1)*by" is the number corresponding to the \(k\)-th probability in probvector.
Josef Leydold and Wolfgang H\"ormann unuran@statmath.wu.ac.at.
These routines generate a sample of discrete random variates with
given probability vector. This vector must be provided by
probvector
, a vector of non-negative numbers which need not
necessarily sum up to 1.
Method ‘DGT’ uses a guide-table based inversion method.
Method ‘DAU’ implements the Alias-Urn method.
Both methods run in constant time, i.e., the marginal sampling times do not depend on the length of the given probability vector. Whereas their setup times grow linearly with this length.
W. H\"ormann, J. Leydold, and G. Derflinger (2004): Automatic Nonuniform Random Variate Generation. Springer-Verlag, Berlin Heidelberg.
H.C. Chen and Y. Asau (1974): On generating random variates from an empirical distribution. AIIE Trans. 6, pp.163--166.
A.J. Walker (1977): An efficient method for generating discrete random variables with general distributions. ACM Trans. Model. Comput. Simul. 3, pp.253--256.
dau.new
, dgt.new
, and ur
for replacement.