Probability – How to Generate a Poisson Random Variable from a Standard Uniform Random Variable

probabilitystatistics

I can't solve the following exercise:

A random number generator generates random values $U \sim \text{U}(0,1)$ from the standard uniform distribution. Use $U$ to generate a random variable $P \sim \text{Pois}(\lambda = 5)$ from a Poisson distribution with rate parameter equal to five.

Comment: In previous tasks I was asked to use $U$ to generate an exponential random variable $E \sim \text{Exp}(\lambda)$. The solution was to take $E \equiv -\tfrac{1}{\lambda} \ln(1-U)$. I think that this can be helpful because of the relation between Poisson distributions and exponential, but I'm not sure.

Best Answer

There are many ways to do this; some of which are more computationally efficient than others. If you want to use a single generated value $U \sim \text{U}(0,1)$ then you can use inverse transform sampling using the cumulative distribution function for the Poisson distribution. This gives the output:

$$P \equiv \min \Bigg\{ p =0,1,2,... \Bigg| U \leqslant \exp(-\lambda) \sum_{i=0}^p \frac{\lambda^p}{p!} \Bigg\}.$$

Alternatively, if you are willing to use multiple independent generated values $U_1,U_2,U_3, ... \sim \text{IID U}(0,1)$ then you can use the fact that a Poisson random variable with parameter $\lambda$ is given by the number of sequential events occurring in time $\lambda$ where the times between the events are independent exponential random variables with unit rate. Applying this relationship yields the alternative method:

$$P \equiv \min \Bigg\{ p =0,1,2,... \Bigg| - \sum_{i=1}^p \ln(1-U_i) \leqslant \lambda \Bigg\}.$$

In both cases you can program these with a simple while loop in an appropriate computational platform with a uniform pseudo-random number generator.

Related Question