Class DiscreteUniformSampler.LargeRangeDiscreteUniformSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.DiscreteUniformSampler.AbstractDiscreteUniformSampler
org.apache.commons.rng.sampling.distribution.DiscreteUniformSampler.LargeRangeDiscreteUniformSampler
- All Implemented Interfaces:
DiscreteSampler
,SharedStateDiscreteSampler
,SharedStateSampler<SharedStateDiscreteSampler>
- Enclosing class:
DiscreteUniformSampler
private static final class DiscreteUniformSampler.LargeRangeDiscreteUniformSampler
extends DiscreteUniformSampler.AbstractDiscreteUniformSampler
Discrete uniform distribution sampler when the range between lower and upper is too large
to fit in a positive integer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
Lower bound.private final int
Upper bound.Fields inherited from class org.apache.commons.rng.sampling.distribution.DiscreteUniformSampler.AbstractDiscreteUniformSampler
rng
-
Constructor Summary
ConstructorsConstructorDescriptionLargeRangeDiscreteUniformSampler
(UniformRandomProvider rng, int lower, int upper) -
Method Summary
Modifier and TypeMethodDescriptionint
sample()
Creates anint
sample.Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.Methods inherited from class org.apache.commons.rng.sampling.distribution.DiscreteUniformSampler.AbstractDiscreteUniformSampler
toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.commons.rng.sampling.distribution.DiscreteSampler
samples, samples
-
Field Details
-
lower
private final int lowerLower bound. -
upper
private final int upperUpper bound.
-
-
Constructor Details
-
LargeRangeDiscreteUniformSampler
LargeRangeDiscreteUniformSampler(UniformRandomProvider rng, int lower, int upper) - Parameters:
rng
- Generator of uniformly distributed random numbers.lower
- Lower bound (inclusive) of the distribution.upper
- Upper bound (inclusive) of the distribution.
-
-
Method Details
-
sample
public int sample()Description copied from interface:DiscreteSampler
Creates anint
sample.- Returns:
- a sample.
-
withUniformRandomProvider
Description copied from interface:SharedStateSampler
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-