Solved – Calculating the probability of a sum of Poisson-distributed random variables

javapoisson distribution

In Java, I have a set of users, each of which has a Poisson-distributed demand with a known mean:

import org.apache.commons.math3.distribution.PoissonDistribution;

public class User {
  private int mean;
  private PoissonDistribution dist;
  public void setMean(int mean) {
      this.mean = mean;
      this.poissonDistribution = new PoissonDistribution(mean);
  }
}

...
User u1 = new User(); u1.setMean(20);
User u2 = new User(); u2.setMean(30);
User u3 = new User(); u3.setMean(40);

Now I'd like to calculate the probability that all Users have a cumulated demand below a certain value:

double probabilityBelowX = calculateCumulatedProbability(50, u1, u2, u3); // <- what must this method look like?

I am stuck at the question, how to solve this problem in Java. Am I missing something in the math package? I know that the demands of the customers are independent, so according to my knowledge about the Poisson distribution I can simply add up the values. But I only have cumulativeProbability(int x) for every single one of the user demands, but not for several at once.

Best Answer

If you assume that customers demands are independant and Poisson, the total demand will be a Poisson distribution as well with parameter equal to the sum of the individual Poisson parameters (see wikipedia for example).

A C++ code example (I am not so familiar with Java):

double cumulative(double x, User * users, int nusers) 
{
    double lambda = 0.;
    for (unsigned i = 0; i < nusers; ++i) lambda += users[i].mean();
    return PoissonDistribution(lambda).cumulativeProbability(x);
}
Related Question