urdgt | R Documentation |
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)
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
|
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.
urdgt() and urdau() are very fast for probvector not longer than about 1000.
Josef Leydold and Wolfgang H\"ormann unuran@statmath.wu.ac.at.
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.