public static double poisson(double k,double x,boolean cum){
  if ((x < 0) || (k < 1)) {
    throw new ArithmeticException("The Poisson Distribution Function requires x>=0 and k >= 1");
  }
  k=k + 1;
  if (cum) {
    return (1.0 - igamma(k,x));
  }
 else {
    return ((Math.exp(-x) * Math.pow(x,k)) / gamma(k));
  }
}

public static double poisson ( double k , double x , boolean cum ) { if ( ( x < 0 ) || ( k < 1 ) ) { throw new ArithmeticException ( "The Poisson Distribution Function requires x>=0 and k >= 1" ) ; } k = k + 1 ; if ( cum ) { return ( 1.0 - igamma ( k , x ) ) ; } else { return ( ( Math . exp ( - x ) * Math . pow ( x , k ) ) / gamma ( k ) ) ; } }
calculates the poisson distribution for mean x and k events for doubles . if third parameter is boolean true , the cumulative poisson function is returned .
