We present and analyze efficient new algorithms for generating a
random variate distributed according to a dynamically changing set
of N weights. The base version of each algorithm generates the
discrete random variate in
expected time and updates a
weight in
expected time in the worst case. We
then show how to reduce the update time to
amortized
expected time. We show how to apply our techniques to a recent lookup
table technique in order to obtain an expected constant time in the
worst case for generation and update. The algorithms are
conceptually simple. We give parallel algorithms for parallel
generation and update having optimal processors-time product. We
also give an efficient dynamic algorithm for maintaining
approximate heaps of N elements; each query is required to return an
element whose value is within an
factor of the maximal
element value. For
,
each query,
insertion, or deletion takes
time.
Keywords: random number generator, random variate, alias, bucket, rejection, dynamic data structure, update, approximate priority queue.