public final class KempSmallMeanPoissonSampler extends Object implements SharedStateDiscreteSampler
This sampler is suitable for mean < 40. For large means,
LargeMeanPoissonSampler should be used instead.
Note: The algorithm uses a recurrence relation to compute the Poisson probability and a rolling summation for the cumulative probability. When the mean is large the initial probability (Math.exp(-mean)) is zero and an exception is raised by the constructor.
Sampling uses 1 call to UniformRandomProvider.nextDouble(). This method provides
an alternative to the SmallMeanPoissonSampler for slow generators of double.
| Modifier and Type | Method and Description |
|---|---|
static SharedStateDiscreteSampler |
of(UniformRandomProvider rng,
double mean)
Creates a new sampler for the Poisson distribution.
|
int |
sample()
Creates an
int sample. |
String |
toString() |
SharedStateDiscreteSampler |
withUniformRandomProvider(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, waitsamples, samplespublic int sample()
int sample.sample in interface DiscreteSamplerpublic SharedStateDiscreteSampler withUniformRandomProvider(UniformRandomProvider rng)
withUniformRandomProvider in interface SharedStateSampler<SharedStateDiscreteSampler>rng - Generator of uniformly distributed random numbers.public static SharedStateDiscreteSampler of(UniformRandomProvider rng, double mean)
rng - Generator of uniformly distributed random numbers.mean - Mean of the distribution.IllegalArgumentException - if mean <= 0 or
Math.exp(-mean) == 0.Copyright © 2016–2022 The Apache Software Foundation. All rights reserved.