In article <a8ff69$[EMAIL PROTECTED]>,
Herman Rubin <[EMAIL PROTECTED]> wrote:
>In article <011301c1d93c$de7d3fe0$fc4434d9@usama1>,
>osama <[EMAIL PROTECTED]> wrote:
>>This is a multi-part message in MIME format.


>>Hallo;
>>    Do you know of a fast algorithm to generate random numbers from a discr=
>>ete distribution? I am looking for a disrtibution with pmf x^a p^x/c
>>Does any of the avaliable stat package do this?

>I know some reasonably fast ways to do this; whether they
>are in the literature I do not know.

Not having received a response, let me give some easy programs
to generate.  The cases a > 0 and a < 0 are different.

For a > 0, the pmf h is log-concave.  This means that one can
use an acceptance-rejection scheme starting with a function
g which is of the form A*q^x, q > 1, for x small, B for x in
the middle range, and C*r^x for x large.  For this particular
problem, it may be that the small part, and possibly even the
middle part, may be absent.  If the analogy with the continuous
log-concave results hold, this should have the expected number
of trials less than 1.6, and typically less than 1.15.

If a < 0, I would suggest breaking the integers into three 
sets, x = 1, 1 < x < m, and x >= m.  The function g to be
normalized would be g(x) = p for x = 1, g(x) = p*x^a in the
middle set, and g(x) = m^a*p*x for x large.  One could even
use that x^a < int y^a from y = x-1 to x (easy to test) or
better from x-.5 to x+.5 (more efficient).  My unpublished
results for the Zeta distribution show that the expected
number of trials separating out the smallest value and 
using this is less than 1.3 in all cases for using the
interval with the larger rejection probability.

One can get more efficiency be reusing test uniform or
test exponential random variables upon acceptance.
-- 
This address is for information only.  I do not claim that these views
are those of the Statistics Department or of Purdue University.
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399
[EMAIL PROTECTED]         Phone: (765)494-6054   FAX: (765)494-0558
.
.
=================================================================
Instructions for joining and leaving this list, remarks about the
problem of INAPPROPRIATE MESSAGES, and archives are available at:
.                  http://jse.stat.ncsu.edu/                    .
=================================================================

Reply via email to