Package cern.jet.random
Class PoissonSlow
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.jet.random.AbstractDistribution
-
- cern.jet.random.AbstractDiscreteDistribution
-
- cern.jet.random.PoissonSlow
-
- All Implemented Interfaces:
DoubleFunction
,IntFunction
,java.io.Serializable
,java.lang.Cloneable
public class PoissonSlow extends AbstractDiscreteDistribution
Poisson distribution; See the math definition and animated definition.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.
- Static methods operate on a default uniform random number generator; they are synchronized.
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".
- Version:
- 1.0, 09/24/99
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected double
cached_alxm
protected double
cached_g
protected double
cached_sq
protected static double[]
cof
protected double
mean
protected static double
MEAN_MAX
protected static PoissonSlow
shared
protected static double
SWITCH_MEAN
-
Fields inherited from class cern.jet.random.AbstractDistribution
randomGenerator
-
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
-
-
Constructor Summary
Constructors Constructor Description PoissonSlow(double mean, RandomEngine randomGenerator)
Constructs a poisson distribution.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static double
logGamma(double xx)
Returns the value ln(Gamma(xx) for xx > 0.int
nextInt()
Returns a random number from the distribution.private int
nextInt(double theMean)
Returns a random number from the distribution; bypasses the internal state.protected int
nextIntSlow()
Returns a random number from the distribution.void
setMean(double mean)
Sets the mean.static int
staticNextInt(double mean)
Returns a random number from the distribution with the given mean.java.lang.String
toString()
Returns a String representation of the receiver.private static void
xstaticSetRandomGenerator(RandomEngine randomGenerator)
Sets the uniform random number generated shared by all static methods.-
Methods inherited from class cern.jet.random.AbstractDiscreteDistribution
nextDouble
-
Methods inherited from class cern.jet.random.AbstractDistribution
apply, apply, clone, getRandomGenerator, makeDefaultGenerator, setRandomGenerator
-
-
-
-
Field Detail
-
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:
- Constant Field Values
-
SWITCH_MEAN
protected static final double SWITCH_MEAN
- See Also:
- Constant Field Values
-
cof
protected static final double[] cof
-
shared
protected static PoissonSlow shared
-
-
Constructor Detail
-
PoissonSlow
public PoissonSlow(double mean, RandomEngine randomGenerator)
Constructs a poisson distribution. Example: mean=1.0.
-
-
Method Detail
-
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 < xx < 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
-
nextInt
private int nextInt(double theMean)
Returns a random number from the distribution; bypasses the internal state.
-
nextIntSlow
protected int nextIntSlow()
Returns a random number from the distribution.
-
setMean
public void setMean(double mean)
Sets the mean.
-
staticNextInt
public static int staticNextInt(double mean)
Returns a random number from the distribution with the given mean.
-
toString
public java.lang.String toString()
Returns a String representation of the receiver.- Overrides:
toString
in classjava.lang.Object
-
xstaticSetRandomGenerator
private static void xstaticSetRandomGenerator(RandomEngine randomGenerator)
Sets the uniform random number generated shared by all static methods.- Parameters:
randomGenerator
- the new uniform random number generator to be shared.
-
-