Class UniformLongSampler.PowerOf2RangeUniformLongSampler
- java.lang.Object
-
- org.apache.commons.rng.sampling.distribution.UniformLongSampler
-
- org.apache.commons.rng.sampling.distribution.UniformLongSampler.PowerOf2RangeUniformLongSampler
-
- All Implemented Interfaces:
LongSampler
,SharedStateLongSampler
,SharedStateSampler<SharedStateLongSampler>
- Enclosing class:
- UniformLongSampler
private static class UniformLongSampler.PowerOf2RangeUniformLongSampler extends UniformLongSampler
Discrete uniform distribution sampler when the range is a power of 2 and greater than 1. This sampler assumes the lower bound of the range is 0.Note: This cannot be used when the range is 1 (2^0) as the shift would be 64-bits which is ignored by the shift operator.
-
-
Field Summary
Fields Modifier and Type Field Description private int
shift
Bit shift to apply to the long sample.-
Fields inherited from class org.apache.commons.rng.sampling.distribution.UniformLongSampler
rng
-
-
Constructor Summary
Constructors Constructor Description PowerOf2RangeUniformLongSampler(UniformRandomProvider rng, long range)
PowerOf2RangeUniformLongSampler(UniformRandomProvider rng, UniformLongSampler.PowerOf2RangeUniformLongSampler source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
sample()
Creates along
sample.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.-
Methods inherited from class org.apache.commons.rng.sampling.distribution.UniformLongSampler
of, 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.LongSampler
samples, samples
-
-
-
-
Constructor Detail
-
PowerOf2RangeUniformLongSampler
PowerOf2RangeUniformLongSampler(UniformRandomProvider rng, long range)
- Parameters:
rng
- Generator of uniformly distributed random numbers.range
- Maximum range of the sample (exclusive). Must be a power of 2 greater than 2^0.
-
PowerOf2RangeUniformLongSampler
PowerOf2RangeUniformLongSampler(UniformRandomProvider rng, UniformLongSampler.PowerOf2RangeUniformLongSampler source)
- Parameters:
rng
- Generator of uniformly distributed random numbers.source
- Source to copy.
-
-
Method Detail
-
sample
public long sample()
Description copied from interface:LongSampler
Creates along
sample.- Returns:
- a sample.
-
withUniformRandomProvider
public UniformLongSampler withUniformRandomProvider(UniformRandomProvider rng)
Description copied from class:UniformLongSampler
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.- Specified by:
withUniformRandomProvider
in interfaceSharedStateSampler<SharedStateLongSampler>
- Specified by:
withUniformRandomProvider
in classUniformLongSampler
- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-
-