public abstract class UniformLongSampler extends Object implements SharedStateLongSampler
long
.
Sampling uses UniformRandomProvider.nextLong()
.
When the range is a power of two the number of calls is 1 per sample.
Otherwise a rejection algorithm is used to ensure uniformity. In the worst
case scenario where the range spans half the range of a long
(263 + 1) the expected number of calls is 2 per sample.
Modifier and Type | Field and Description |
---|---|
protected UniformRandomProvider |
rng
Underlying source of randomness.
|
Modifier and Type | Method and Description |
---|---|
static UniformLongSampler |
of(UniformRandomProvider rng,
long lower,
long upper)
Creates a new discrete uniform distribution sampler.
|
String |
toString() |
abstract UniformLongSampler |
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, wait
sample, samples, samples
protected final UniformRandomProvider rng
public abstract UniformLongSampler withUniformRandomProvider(UniformRandomProvider rng)
withUniformRandomProvider
in interface SharedStateSampler<SharedStateLongSampler>
rng
- Generator of uniformly distributed random numbers.public static UniformLongSampler of(UniformRandomProvider rng, long lower, long upper)
rng
- Generator of uniformly distributed random numbers.lower
- Lower bound (inclusive) of the distribution.upper
- Upper bound (inclusive) of the distribution.IllegalArgumentException
- if lower > upper
.Copyright © 2016–2022 The Apache Software Foundation. All rights reserved.