public static int poisson(double lambda){
  if (!(lambda > 0.0))   throw new IllegalArgumentException("Parameter lambda must be positive");
  if (Double.isInfinite(lambda))   throw new IllegalArgumentException("Parameter lambda must not be infinite");
  int k=0;
  double p=1.0;
  double expLambda=Math.exp(-lambda);
  do {
    k++;
    p*=uniform();
  }
 while (p >= expLambda);
  return k - 1;
}

public static int poisson ( double lambda ) { if ( ! ( lambda > 0.0 ) ) throw new IllegalArgumentException ( "Parameter lambda must be positive" ) ; if ( Double . isInfinite ( lambda ) ) throw new IllegalArgumentException ( "Parameter lambda must not be infinite" ) ; int k = 0 ; double p = 1.0 ; double expLambda = Math . exp ( - lambda ) ; do { k ++ ; p *= uniform ( ) ; } while ( p >= expLambda ) ; return k - 1 ; }
returns a random integer from a poisson distribution with mean & lambda ; .
