src/main/java/org/teachingextensions/logo/utils/MazeUtils/StdRandom.java
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");
    // using algorithm given by Knuth
    // see http://en.wikipedia.org/wiki/Poisson_distribution
    int k = 0;
    double p = 1.0;
    double L = Math.exp(-lambda);
    do
    {
      k++;
      p *= uniform();
    }
    while (p >= L);
    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");
    // using algorithm given by Knuth
    // see http://en.wikipedia.org/wiki/Poisson_distribution
    int k = 0;
    double p = 1.0;
    double L = Math.exp(-lambda);
    do
    {
      k++;
      p *= uniform();
    }
    while (p >= L);
    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" ) ; // using algorithm given by Knuth // see http://en.wikipedia.org/wiki/Poisson_distribution int k = 0 ; double p = 1.0 ; double L = Math . exp ( - lambda ) ; do { k ++ ; p *= uniform ( ) ; } while ( p >= L ) ; return k - 1 ; }
Returns a random integer from a Poisson distribution with mean &lambda;.

@param  lambda the mean of the Poisson distribution
@return a random integer from a Poisson distribution with mean <tt>lambda</tt>
@throws IllegalArgumentException unless <tt>lambda > 0.0</tt> and not infinite
Returns a random integer from a Poisson distribution with mean &lambda ; .