Re: generate binomial distributed random numbers



mueale5@xxxxxxxxxxxxx writes:

Hello!
Is there a very fast algorithm for generating binomial distributed
random numbers. Exactly:

I have an container with N balls (N1 white and N2 black ones).
How many black and white balls will I have in it after taking away
M balls and adding M new ones from an reservoir (with probability
p of adding a white one).

Of course, binomial distribution is only a special case for N=M.

I don't want to simulate every single event to take away a ball
or adding a new one. Is there an algorithm that works in constant
time - or at least in logarithmic time? For example with the help
of a lookup table.
In my program, N is around 2000 - but I want to calculate the new
number of balls billions of times.

Calculate the cumulative distribution function F(x) = Prob(X <= x)
for integers x from 0 to N. Let u be a random number with uniform
distribution in [0,1], and return x where F(x-1) < u <= F(x), found
by binary search.
--
Robert Israel israel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia Vancouver, BC, Canada
.



Relevant Pages

  • Re: Beta-distribution: physical meaning
    ... "k black balls and N-k red balls in a sample of N balls from a ... population with a known fraction of black and red balls". ... distribution is an analytic continuation of the binomial distribution. ... function for events such as "drawing between 1.7 and 2.3 black balls" ...
    (sci.physics)
  • generate binomial distributed random numbers
    ... Is there a very fast algorithm for generating binomial distributed ... I have an container with N balls. ... binomial distribution is only a special case for N=M. ...
    (sci.math)
  • Re: Infinity......
    ... large container. ... If we start by removing 2 balls from ... You can always remove balls according to your rules in such a way you leave the container empty, or with a finite or even infinite number of balls. ...
    (sci.math)
  • Re: Infinity......
    ... large container. ... If we start by removing 2 balls from ... You can always remove balls according to your rules in such a way you leave the container empty, or with a finite or even infinite number of balls. ...
    (sci.math)
  • Re: Infinity......
    ... large container. ... If we start by removing 2 balls from ... You can always remove balls according to your rules in such a way you leave the container empty, or with a finite or even infinite number of balls. ...
    (sci.math)

Quantcast