SoftNet-Consult Java Utility Library

com.softnetConsult.utils.random
Class Poisson

java.lang.Object
  extended by com.softnetConsult.utils.random.Poisson

public class Poisson
extends java.lang.Object

Creates Poisson-distributed pseudorandom numbers.

This product includes software developed by the SoftNet-Consult Java Utility Library project and its contributors.
(http://java-tools.sourceforge.net)
Copyright (c) 2007-2008 SoftNet-Consult.
Copyright (c) 2007-2008 G. Paperin.
All rights reserved.

File: Poisson.java
Library API version: "2.02"
Java compliance version: "1.5"

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following terms and conditions are met:

1. Redistributions of source code must retain the above acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software or any derived software must display the following acknowledgement:
This product includes software developed by the SoftNet-Consult Java Utility Library project and its contributors.

THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version:
"2.02"
Author:
Greg Paperin (http://www.paperin.org)

Field Summary
static double DEFAULT_EPSILON
          Default value for epsilon when no other value is specified.
private  double epsilon
          Specifies the completeness of the CDF table - the table is calculated until the approximated CDF value reaches 1.0 - epsilon.
private  double lambda
          The lambda parameter of this Poisson distribution.
private  java.util.Random rndSource
          The source of uniformly independently distributed random numbers.
private  double[] table
          The CDF table.
 
Constructor Summary
Poisson(double lambda)
          Creates a generator for Poisson distributed random numbers with the specified lambda-parameter.
Poisson(double lambda, java.util.Random rndSource)
          Creates a generator for Poisson distributed random numbers with the specified lambda-parameter and the specified source of random numbers.
Poisson(double lambda, java.util.Random rndSource, double epsilon)
          Creates a generator for Poisson distributed random numbers.
 
Method Summary
 double getEpsilon()
          The epsilon value used during the calculation of the CDF table.
 double getLambda()
          Returns expected mean and variance of this Poisson distribution.
 int nextRandom()
          Generates a new (pseudo-) random integer number from this Poisson-distribution.
private  int tableSearch(double dice)
          Used internally to look up the value of the inverse of the cumulative distribution function of the Poisson distribution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EPSILON

public static final double DEFAULT_EPSILON
Default value for epsilon when no other value is specified.


epsilon

private double epsilon
Specifies the completeness of the CDF table - the table is calculated until the approximated CDF value reaches 1.0 - epsilon.


lambda

private double lambda
The lambda parameter of this Poisson distribution. Both, the mean and the variance of a Poisson-distributed random variable are equal to lambda.


table

private double[] table
The CDF table.


rndSource

private java.util.Random rndSource
The source of uniformly independently distributed random numbers.

Constructor Detail

Poisson

public Poisson(double lambda)
Creates a generator for Poisson distributed random numbers with the specified lambda-parameter. Calling this constructor is equivalent to Poisson(lambda, new Random(), Poisson.DEFAULT_EPSILON).

Parameters:
lambda - The LAMBDA-parameter to the Poisson distribution.
See Also:
Poisson(double, Random, double)

Poisson

public Poisson(double lambda,
               java.util.Random rndSource)
Creates a generator for Poisson distributed random numbers with the specified lambda-parameter and the specified source of random numbers. Calling this constructor is equivalent to Poisson(lambda, rndSource, Poisson.DEFAULT_EPSILON).

Parameters:
lambda - The LAMBDA-parameter to the Poisson distribution.
rndSource - The source of uniformly independently distributed (pseudo-) random numbers to use for this distribution.
See Also:
Poisson(double, Random, double)

Poisson

public Poisson(double lambda,
               java.util.Random rndSource,
               double epsilon)
Creates a generator for Poisson distributed random numbers.

Parameters:
lambda - The LAMBDA parameter for this Poisson distribution. Both, the mean and the variance of a Poisson-distributed random variable are equal to lambda.
rndSource - The source of uniformly independently distributed (pseudo-) random numbers to use for this distribution.
epsilon - Completeness threshold used during the computation of the cumulative distribution function table. The CDF table is calculated until the approximated CDF value reaches 1.0 - epsilon.
Method Detail

getLambda

public double getLambda()
Returns expected mean and variance of this Poisson distribution.

Returns:
The LAMBDA parameter of this Poisson distribution.

getEpsilon

public double getEpsilon()
The epsilon value used during the calculation of the CDF table.

Returns:
Completeness threshold used during the computation of the cumulative distribution function table. The CDF table is calculated until the approximated CDF value reaches 1.0 - epsilon.

nextRandom

public int nextRandom()
Generates a new (pseudo-) random integer number from this Poisson-distribution.

Returns:
A new Poisson-distributed integer.

tableSearch

private int tableSearch(double dice)
Used internally to look up the value of the inverse of the cumulative distribution function of the Poisson distribution.

Parameters:
dice - A number in interval [0, 1]
Returns:
The smallest integer k such that dice <= CDF(k), where CDF is the cumulative distribution function of this Poisson distribution.

SoftNet-Consult Java Utility Library is a member of SourceForge.net