tmn
tmn

Reputation: 31

Java: Poisson-based point process constrained in a small region

While simulating a random point process based on Poisson distribution that contains 1000 dots; they all appear to occupy a small region in the center of the window.

I used Donald Knuth inverse sampling algorithm to implement the Poisson-based pseudo-random number generator.

https://en.wikipedia.org/wiki/Poisson_distribution#Generating_Poisson-distributed_random_variables

Lambda value (aka the success rate) was set to window_dimension/2, and obtained this result (screenshot)

Point-process using poisson-based pseudo-random generator

Code:

public double getPoisson(double lambda) {//250
    double L = Math.exp(-lambda);
    double p = 1d;
    int k = 0;
    do {
        k++;
        p *= Math.random();
    } while (p > L);

    return k-1;
}

`

Upvotes: 0

Views: 390

Answers (1)

pjs
pjs

Reputation: 19855

It looks to me like the problem is with what you think the output should be, because the program seems to be generating pretty much what you asked. A Poisson with a rate of 500 will have both its expected value and its variance equal to 500, and for large values of λ it's pretty symmetric and bell-shaped. Taken together that all means the standard deviation is sqrt(500), which is slightly less than 22.4, so you should expect about 95% of your incomes to be 500±45, which looks like what you're getting.

With your subsequent edit saying (in a comment) that λ=250, the results behave similarly. The likely range of outcomes in each dimension is 250±31, still clustering to the center.

It's easy to confirm my explanation by creating Poisson random variates with a standard deviation such that ±3σ span your plot area. You need a larger variance/standard deviation to increase the spread of outcomes across your window. To demo this, I went with a Poisson(6400)—which has a standard deviation of 80—and subtracted 6150 to give the result a mean of 250. The overwhelming majority of values will therefore fall between 0 and 500. I generated 1000 independent pairs of values and plotted them using the JMP statistics package, and here are the results:

Plot of pairs of (Poisson(6400)-6150) random variates

and just for jollies, here's a plot of independent pairs of Normal(250, 80)'s:

enter image description here

They look pretty darn similar, don't they?

To reiterate, there's nothing wrong with the Poisson algorithm you used. It's doing exactly what you told it to do, even if that's not what you expected the results to look like.


Addendum

Since you don't believe that Poisson converges to Gaussian as lambda grows, here's some direct evidence for your specific case, again generated with JMP:

Histogram and normal distribution fit results for Poisson(250)

On the left is a histogram of 1000 randomly generated Poisson(250) values. Note the well-formed bell shape. I had JMP select the best continuous distribution fit based on AIC (Aikaike Information Criterion). It selected normality as the best possible fit, with the diagnostics on the right and the resulting density plot in red superimposed on the histogram. The results pretty much speak for themselves.

Upvotes: 3

Related Questions