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)
probvector
, a vector of non-negative numbers which need not
necessarily sum up to 1. Method
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.
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.