Question

I'm working with the random number generator available within C++11. At the moment, I'm using a uniform distribution, which should give me an equal probability to get any number within the range A & B which I specify.

However, I'm confused about generating Poisson distributions. While I understand how to determine the Poisson probability, I don't understand how a random series of numbers can be "distributed" based on the Poisson distribution.

For instance, the C++11 constructor for a Poisson distribution takes one argument -- λ, which is the mean of the distribution

std::tr1::poisson_distribution<double> poisson(7.0);
std::cout << poisson(eng) << std::endl;

In a Poisson probability problem, this is equal to the expected number of successes / occurrences during a given interval. However, I don't understand what it represents in this instance. What is a "success" / "occurrence" in a random number scenario?

I appreciate any assistance or reference materials which I can use to help me understand this.

Was it helpful?

Solution

The probability of a Poisson distribution is the chance a specific value occurs. Imagine you want to calculate how many cars pass a certain point each day. This value will be more some days, but less on other days. But when keeping track of this over a serious amount of time, a mean will start to emerge, with values in its vicinity occurring more often, and values further away (0 cars per day or a tenfold amount) being less likely. λ is that mean that emerged.

When reflecting this to RNG's, the algorithm would return you the amount of cars that passed on a random day (which is selected uniformly). As you can imagine the mean value λ is more likely to emerge, and the extremes are least likely to pop up.

The following link has an example of the distribution Poisson has, showing the discrete results you acquire, and the chance each of them has of occurring:

http://www.mathworks.com/help/toolbox/stats/brn2ivz-127.html

A sample implementation could calculate for each value the probability it occurs, and then calculate ranges based on these values to translate a uniform distribution to Poisson. e.g. for λ == 2 we have 13% chance for 0, 27% chance for 1, 27% chance for 2... Then we generate a good old uniform random number between 0.0 and 1.0. If this number is <= 0.13 return 0. Is it <= 0.40 return 1. Is it <= 0.67 return 2 etc...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top