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.

  • $\begingroup$ If the demands are $X_1$,$X_2$, & $X_3$, & your certain value is $k$, do you want to calculate (1) the probability that the total demand is less than a certain value $\mathrm{P}(X_1+X_2+X_3<k)$, or (2) the joint probability that demand for each user is less than a certain value $\mathrm{P}(X_1<k,X_2<k,X_3<k)$? $\endgroup$ – Scortchi - Reinstate Monica Jan 11 '13 at 9:31
  • $\begingroup$ @Scortchi the first one: I want to know the probability that the aggregated demand is below a given value: $P(X_1 + X_2 + X_3 < k)$ $\endgroup$ – DaDaDom Jan 11 '13 at 9:36

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);
  • $\begingroup$ Thank you, I will try this in my Java code and give a feedback once I got it implemented. I just didn't know or wasn't sure, that I could simply add up the single means - it just seemed to be too simple! $\endgroup$ – DaDaDom Jan 11 '13 at 9:47
  • $\begingroup$ OK, it works. Here is the Java code: double totalDemand = 0; for (User u : tour.getUsers()) {totalDemand += u.getMean();} double cumulativeProbability = new PoissonDistribution(totalDemand).cumulativeProbability(50); $\endgroup$ – DaDaDom Jan 11 '13 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.