Class PoissonDoubleRV

All Implemented Interfaces:
Cloneable, RandomVariableOps<Double>

public class PoissonDoubleRV extends DoubleRandomVariable
Double-valued random variable with a Poisson distribution. If X is a random variable with a Poisson distribution that has a parameter λ, the the probability that X = k is given by
ke)/k!
The sequence of double-precision numbers generated by instances of this class are values of k with the distribution given above, provided the values are not so large that successive integers cannot be distinguished.

The algorithms used are the following.

  • Table lookup: used for λ≤745 and when a table is available. A table, if not currently cached, is created when λ≤745 and the second argument of the two-argument constructor has the value true. The table may be removed by the garbage collector, although the method PoissonTable.add(double) can be used to create a persistent table. This algorithm is basically inverse transform sampling with pre-computed values and a binary search to find the inverse. The limit on λ is set by numerical-accuracy constraints.
  • Inverse transform sampling: used for λ≤18. The inverse is found by computing the CDF for increasing values of k until the value for the CDF is larger than a uniformly distributed random number (computed once).
  • The PTRD algorithm (Wolfgang Hörmann, "The Transformed Rejection Method for Generating Poisson Random Variables," page 6, Virtschaftsuniversität Wien, April 1992, http://epub.wu.ac.at/352/1/document.pdf): used for 18<λ<225.
  • Approximation via a normal distribution: used for λ≥225.
  • Constructor Details

    • PoissonDoubleRV

      public PoissonDoubleRV(double lambda)
      Constructor.
      Parameters:
      lambda - the rate of the Poisson distribution (equal to its mean and to its variance).
    • PoissonDoubleRV

      public PoissonDoubleRV(double lambda, boolean mode)
      Constructor with a mode to allow tables to be allocated. If tables are requested and the value of lambda is too large, the request will be ignored.
      Parameters:
      lambda - the rate of the Poisson distribution (equal to its mean and to its variance)
      mode - true if tables should be allocated to improve execution speed; false otherwise
  • Method Details

    • getMean

      public double getMean()
      Get the mean value for the random-variable.
      Returns:
      the mean value
    • getSDev

      public double getSDev()
      Get the standard deviation for the random variable.
      Returns:
      the standard deviation
    • next

      public Double next()
      Get the next value.
      Specified by:
      next in interface RandomVariableOps<Double>
      Specified by:
      next in class RandomVariable<Double>
      Returns:
      an integer giving a value from a Poisson distribution