Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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)$? – Scortchi Jan 11 '13 at 9:31
@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)$ – DaDaDom Jan 11 '13 at 9:36
up vote 3 down vote accepted

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);
share|improve this answer
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! – DaDaDom Jan 11 '13 at 9:47
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); – DaDaDom Jan 11 '13 at 18:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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