Package sim.util.distribution
Class PoissonSlow
java.lang.Object
sim.util.distribution.AbstractDistribution
sim.util.distribution.AbstractDiscreteDistribution
sim.util.distribution.PoissonSlow
- All Implemented Interfaces:
Serializable
Poisson distribution; See the math definition
and animated definition.
Static methods operate on a default uniform random number generator; they are synchronized.
p(k) = (mean^k / k!) * exp(-mean) for k >= 0.
Valid parameter ranges: mean > 0. Note: if mean <= 0.0 then always returns zero.
Instance methods operate on a user supplied uniform random number generator; they are unsynchronized.
Implementation: This is a port of RandPoisson used in CLHEP 1.4.0 (C++). CLHEP's implementation, in turn, is based upon "W.H.Press et al., Numerical Recipes in C, Second Edition".
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected double
protected double
protected double
protected static final double[]
protected double
protected static final double
protected static final double
Fields inherited from class sim.util.distribution.AbstractDistribution
randomGenerator
-
Constructor Summary
ConstructorDescriptionPoissonSlow
(double mean, MersenneTwisterFast randomGenerator) Constructs a poisson distribution. -
Method Summary
Modifier and TypeMethodDescriptionstatic double
logGamma
(double xx) Returns the value ln(Gamma(xx) for xx > 0.int
nextInt()
Returns a random number from the distribution.protected int
Returns a random number from the distribution.void
setMean
(double mean) Sets the mean.toString()
Returns a String representation of the receiver.Methods inherited from class sim.util.distribution.AbstractDiscreteDistribution
nextDouble
Methods inherited from class sim.util.distribution.AbstractDistribution
apply, apply, getRandomGenerator, setRandomGenerator
-
Field Details
-
mean
protected double mean -
cached_sq
protected double cached_sq -
cached_alxm
protected double cached_alxm -
cached_g
protected double cached_g -
MEAN_MAX
protected static final double MEAN_MAX- See Also:
-
SWITCH_MEAN
protected static final double SWITCH_MEAN- See Also:
-
cof
protected static final double[] cof
-
-
Constructor Details
-
PoissonSlow
Constructs a poisson distribution. Example: mean=1.0.
-
-
Method Details
-
logGamma
public static double logGamma(double xx) Returns the value ln(Gamma(xx) for xx > 0. Full accuracy is obtained for xx > 1. For 0 invalid input: '<' xx invalid input: '<' 1. the reflection formula (6.1.4) can be used first. (Adapted from Numerical Recipes in C) -
nextInt
public int nextInt()Returns a random number from the distribution.- Specified by:
nextInt
in classAbstractDiscreteDistribution
-
nextIntSlow
protected int nextIntSlow()Returns a random number from the distribution. -
setMean
public void setMean(double mean) Sets the mean. -
toString
Returns a String representation of the receiver.
-