# Using Poisson distribution to generate random integers

I'm trying to generate random integers which have Poisson distribution. The open source library GSL has one such distribution.

Function: unsigned int gsl_ran_poisson (const gsl_rng * r, double mu) This function returns a random integer from the Poisson distribution with mean mu. The probability distribution for Poisson variates is p(k) = {mu^k over k!} exp(-mu)

I want to know what it actually returns. Does it return k for a particular value of p(k)?

For a particular value of mu, k can take values from 0,1,2,3... So if I specify a value for mu, do I have an upper bound on the values returned by this function?

• No, there is no upper bound on the Poisson distribution. – Neil G Apr 3 '14 at 4:09
• if you want an upper bound, you could truncate it at something large and redraw when it gets over the bound... – Memming Apr 3 '14 at 5:07
• Thanks. And is my understanding that the function returns k correct? – arunmoezhi Apr 3 '14 at 5:36

I'm trying to generate random integers which have Poisson distribution.
I want to know what it actually returns. Does it return k for a particular value of p(k)?

No. The part you quoted describes what it does quite clearly. It returns a random $X$ which has $P(X=k)=p(k)$. If you tell it $\mu$ you'll get a set of random counts from a Poisson($\mu$) distribution.

For a particular value of $\mu$, $k$ can take values from 0,1,2,3...
So if I specify a value for $\mu$, do I have an upper bound on the values returned by this function?

No. For any fixed value $M$, there's still some chance of exceeding $M$, though it may be vanishingly small. (Well, because it's implemented on a computer with finite precision, there's always some limit - you can't store something bigger than the biggest integer, for example - and the exact behavior as it approaches or goes beyond whatever limit exists depend on implementation.)

• Thanks. When you say it returns X, doesn't it mean k because P(X=k) means probability that X takes a value k – arunmoezhi Apr 3 '14 at 5:57
• $X$ is the random variable while in the pmf, $k$ indexes the values it can take. The random variable is denoted $X$ up to the point you observe it. Once you observe it (or in this case, generate it), it takes some particular value, $x$, say. You should feel free to call that observed value $k$ as long as you don't get confused between the observed value and the dummy over the domain of the variable. – Glen_b -Reinstate Monica Apr 3 '14 at 6:03
• Thanks again. Another question. Lets say I have a list of 400 uniform random numbers between 1 and 1000. On this list I want to do isPresent(x) where x is a variable obtained from Poisson distribution. Now for the mu I choose 500. Is this practical? If I choose a value of mu as say 3, I get numbers close to 3 and on the big list of 400 numbers I would be searching only a handful of numbers. So does my choice of mu as 500 make sense? – arunmoezhi Apr 3 '14 at 6:16
• I'm not sure what you mean by practical here. What are the properties you seek/what are the limitations you want/need? Note that making the mean of the Poisson 500, you'll usually only observe a range covering about 120-150 values. The largest value will generally be up around 560-580 and the smallest around 425-445. The number of unique values will be close to but typically a bit less than 100. – Glen_b -Reinstate Monica Apr 3 '14 at 6:32
• You kind of answered my question. I was looking for a Poisson distribution which would have maximum coverage. If I choose mu as 3 then I would get values from 0 to 6. But my list can have numbers from 1 to 1000. So I think I can get a maximum coverage if I choose 1000/2 which is 500. Am I correct? – arunmoezhi Apr 3 '14 at 6:44