urdgt {Runuran} | R Documentation |
UNU.RAN discrete random variate generator
Description
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. ]
Usage
urdgt(n, probvector, from = 0, by = 1)
urdau(n, probvector, from = 0, by = 1)
Arguments
n |
size of required sample. |
probvector |
vector of non-negative numbers (need not sum to 1). |
from |
number corresponding to the first probability in probvector. |
by |
"from + (k-1)*by" is the number corresponding to the
|
Details
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.
Note
urdgt() and urdau() are very fast for probvector not longer than about 1000.
Author(s)
Josef Leydold and Wolfgang H\"ormann unuran@statmath.wu.ac.at.
References
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.
See Also
dau.new
, dgt.new
, and ur
for replacement.