common
Class Poisson

java.lang.Object
  extended by common.Poisson
All Implemented Interfaces:
IntegerDist, java.io.Serializable

public class Poisson
extends java.lang.Object
implements IntegerDist, java.io.Serializable

A Poisson distribution with mean and variance lambda. This is a distribution over non-negative integers. The probability of n is exp(-lambda) lambda^n / n!.

See Also:
Serialized Form

Constructor Summary
Poisson()
          Creates a new Poisson distribution with lambda = 1.
Poisson(double lambda)
          Creates a new Poisson distribution with the specifies lambda parameter.
 
Method Summary
 double getLogProb(int n)
          Returns the log probability of the integer n under this distribution.
 double getProb(int n)
          Returns the probability of the integer n under this distribution.
 int sample()
          Returns an integer sampled according to this distribution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Poisson

public Poisson()
Creates a new Poisson distribution with lambda = 1.


Poisson

public Poisson(double lambda)
Creates a new Poisson distribution with the specifies lambda parameter.

Method Detail

getProb

public double getProb(int n)
Returns the probability of the integer n under this distribution.

Specified by:
getProb in interface IntegerDist

getLogProb

public double getLogProb(int n)
Returns the log probability of the integer n under this distribution.

Specified by:
getLogProb in interface IntegerDist

sample

public int sample()
Returns an integer sampled according to this distribution. This implementation takes time proportional to the magnitude of the integer returned. I got the algorithm from Anuj Kumar's course page for IEOR E4404 at Columbia University, specifically the file:
http://www.columbia.edu/~ak2108/ta/summer2003/poisson1.c

Specified by:
sample in interface IntegerDist