DiscreteSampler, SharedStateDiscreteSampler, SharedStateSampler<SharedStateDiscreteSampler>public class SmallMeanPoissonSampler extends java.lang.Object 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.
This sampler is suitable for mean < 40.
For large means, LargeMeanPoissonSampler should be used instead.
Sampling uses UniformRandomProvider.nextDouble() and requires on average
mean + 1 deviates per sample.
| Constructor | Description |
|---|---|
SmallMeanPoissonSampler(org.apache.commons.rng.UniformRandomProvider rng,
double mean) |
| Modifier and Type | Method | Description |
|---|---|---|
static SharedStateDiscreteSampler |
of(org.apache.commons.rng.UniformRandomProvider rng,
double mean) |
Creates a new sampler for the Poisson distribution.
|
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.
|
public SmallMeanPoissonSampler(org.apache.commons.rng.UniformRandomProvider rng, double mean)
rng - Generator of uniformly distributed random numbers.mean - Mean.java.lang.IllegalArgumentException - if mean <= 0 or Math.exp(-mean) == 0public int sample()
sample in interface DiscreteSamplerpublic java.lang.String toString()
toString in class java.lang.Objectpublic 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 of the distribution.java.lang.IllegalArgumentException - if mean <= 0 or Math.exp(-mean) == 0.Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.