[math/distributions/poisson] extract Poisson-distributed random variate?
I've searched the Boost documentation and mail archive, but I can't find an example for extracting a random variate from a Poisson distribution. What I want to do is similar to extracting a variate from a uniform distribution, such as the C++ rand() function, which returns a single random variate on the range [0, RAND_MAX]. Is there a way to do something similar using the Poisson distribution with a given mean? For example, something like this: double n, lambda(0.30); //lambda is the mean of the Poisson n = poisson_rand(lambda); Thanks, Mike
Michael Fuller wrote:
I've searched the Boost documentation and mail archive, but I can't find an example for extracting a random variate from a Poisson distribution. What I want to do is similar to extracting a variate from a uniform distribution, such as the C++ rand() function, which returns a single random variate on the range [0, RAND_MAX].
Is there a way to do something similar using the Poisson distribution with a given mean? For example, something like this:
double n, lambda(0.30); //lambda is the mean of the Poisson n = poisson_rand(lambda);
Try boost/random/poisson_distribution.hpp, unfortunately appears not to be documented, but usage is the same as the other distributions in Boost.Random. HTH, John.
John Maddock
Try boost/random/poisson_distribution.hpp, unfortunately appears not to be documented, but usage is the same as the other distributions in Boost.Random.
HTH, John.
Excellent, thanks John. Walking home last night I realized that another approach might be to use a uniform random number as the argument to the pdf function. Mike
Michael Fuller wrote:
John Maddock
writes: Try boost/random/poisson_distribution.hpp, unfortunately appears not to be documented, but usage is the same as the other distributions in Boost.Random.
HTH, John.
Excellent, thanks John. Walking home last night I realized that another approach might be to use a uniform random number as the argument to the pdf function.
Um, argument to the quantile function surely? John.
John Maddock
Um, argument to the quantile function surely?
Oops, yes, the quantile function.
I eventually found what I was looking for in some code written by
Joaquín M López Muñoz.
For the sake of closure, here is an example:
//Generate a Poisson-distributed random variate given a
//specific mean value):
#include
participants (2)
-
John Maddock
-
Michael Fuller