Package org.uncommons.maths.random
Class PoissonGenerator
- java.lang.Object
-
- org.uncommons.maths.random.PoissonGenerator
-
- All Implemented Interfaces:
NumberGenerator<java.lang.Integer>
public class PoissonGenerator extends java.lang.Object implements NumberGenerator<java.lang.Integer>
Discrete random sequence that follows a Poisson distribution.
-
-
Field Summary
Fields Modifier and Type Field Description private NumberGenerator<java.lang.Double>meanprivate java.util.Randomrng
-
Constructor Summary
Constructors Constructor Description PoissonGenerator(double mean, java.util.Random rng)Creates a generator of Poisson-distributed values from a distribution with the specified mean.PoissonGenerator(NumberGenerator<java.lang.Double> mean, java.util.Random rng)Creates a generator of Poisson-distributed values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.IntegernextValue()
-
-
-
Field Detail
-
rng
private final java.util.Random rng
-
mean
private final NumberGenerator<java.lang.Double> mean
-
-
Constructor Detail
-
PoissonGenerator
public PoissonGenerator(NumberGenerator<java.lang.Double> mean, java.util.Random rng)
Creates a generator of Poisson-distributed values. The mean is determined by the provided
NumberGenerator. This means that the statistical parameters of this generator may change over time. One example of where this is useful is if the mean generator is attached to a GUI control that allows a user to tweak the parameters while a program is running.To create a Poisson generator with a constant mean, use the
PoissonGenerator(double, Random)constructor instead.- Parameters:
mean- ANumberGeneratorthat provides the mean of the Poisson distribution used for the next generated value.rng- The source of randomness.
-
PoissonGenerator
public PoissonGenerator(double mean, java.util.Random rng)Creates a generator of Poisson-distributed values from a distribution with the specified mean.- Parameters:
mean- The mean of the values generated.rng- The source of randomness.
-
-
Method Detail
-
nextValue
public java.lang.Integer nextValue()
- Specified by:
nextValuein interfaceNumberGenerator<java.lang.Integer>- Returns:
- The next value from the generator.
-
-