DiscreteSampler
, SharedStateDiscreteSampler
, SharedStateSampler<SharedStateDiscreteSampler>
public class PoissonSampler extends SamplerBase implements SharedStateDiscreteSampler
Knuth (1969). Seminumerical Algorithms. The Art of Computer Programming, Volume 2. Chapter 3.4.1.F.3 Important integer-valued distributions: The Poisson distribution. Addison Wesley.The Poisson process (and hence, the returned value) is bounded by
1000 * mean
.
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)
Constructor | Description |
---|---|
PoissonSampler(org.apache.commons.rng.UniformRandomProvider rng,
double mean) |
This instance delegates sampling.
|
Modifier and Type | Method | Description |
---|---|---|
static SharedStateDiscreteSampler |
of(org.apache.commons.rng.UniformRandomProvider rng,
double mean) |
Creates a new Poisson distribution sampler.
|
int |
sample() |
Creates a sample.
|
java.lang.String |
toString() |
|
SharedStateDiscreteSampler |
withUniformRandomProvider(org.apache.commons.rng.UniformRandomProvider rng) |
Create a new instance of the sampler with the same underlying state using the given
uniform random provider as the source of randomness.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
nextDouble, nextInt, nextInt, nextLong
public PoissonSampler(org.apache.commons.rng.UniformRandomProvider rng, double mean)
of(UniformRandomProvider, double)
to create an optimal sampler.rng
- Generator of uniformly distributed random numbers.mean
- Mean.java.lang.IllegalArgumentException
- if mean <= 0
or
mean >
Integer.MAX_VALUE
.public int sample()
sample
in interface DiscreteSampler
public java.lang.String toString()
toString
in class SamplerBase
public SharedStateDiscreteSampler withUniformRandomProvider(org.apache.commons.rng.UniformRandomProvider rng)
withUniformRandomProvider
in interface SharedStateSampler<SharedStateDiscreteSampler>
rng
- Generator of uniformly distributed random numbers.public static SharedStateDiscreteSampler of(org.apache.commons.rng.UniformRandomProvider rng, double mean)
rng
- Generator of uniformly distributed random numbers.mean
- Mean.java.lang.IllegalArgumentException
- if mean <= 0
or mean >
Integer.MAX_VALUE
.Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.