Class PoissonSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.SamplerBase
org.apache.commons.rng.sampling.distribution.PoissonSampler
- All Implemented Interfaces:
DiscreteSampler
public class PoissonSampler extends SamplerBase implements DiscreteSampler
Sampler for the Poisson distribution.
- For small means, a Poisson process is simulated using uniform deviates, as described here. The Poisson process (and hence, the returned value) is bounded by 1000 * mean.
-
For large means, we use the rejection algorithm described in
Devroye, Luc. (1981). The Computer Generation of Poisson Random Variables
Computing vol. 26 pp. 197-207.
Sampling uses:
UniformRandomProvider.nextDouble()UniformRandomProvider.nextLong()(large means only)
- Since:
- 1.0
-
Constructor Summary
Constructors Constructor Description PoissonSampler(UniformRandomProvider rng, double mean) -
Method Summary
Methods inherited from class org.apache.commons.rng.sampling.distribution.SamplerBase
nextDouble, nextInt, nextInt, nextLong
-
Constructor Details
-
PoissonSampler
- Parameters:
rng- Generator of uniformly distributed random numbers.mean- Mean.- Throws:
java.lang.IllegalArgumentException- ifmean <= 0ormean >Integer.MAX_VALUE.
-
-
Method Details
-
sample
public int sample()Creates a sample.- Specified by:
samplein interfaceDiscreteSampler- Returns:
- a sample.
-
toString
public java.lang.String toString()- Overrides:
toStringin classSamplerBase
-