Class DiscreteUniformSampler
- java.lang.Object
-
- org.apache.commons.rng.sampling.distribution.SamplerBase
-
- org.apache.commons.rng.sampling.distribution.DiscreteUniformSampler
-
- All Implemented Interfaces:
DiscreteSampler
public class DiscreteUniformSampler extends SamplerBase implements DiscreteSampler
Discrete uniform distribution sampler.Sampling uses
UniformRandomProvider.nextInt(int)when the range(upper - lower) <Integer.MAX_VALUE, otherwiseUniformRandomProvider.nextInt().- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description DiscreteUniformSampler(UniformRandomProvider rng, int lower, int upper)
-
Method Summary
-
Methods inherited from class org.apache.commons.rng.sampling.distribution.SamplerBase
nextDouble, nextInt, nextInt, nextLong
-
-
-
-
Constructor Detail
-
DiscreteUniformSampler
public DiscreteUniformSampler(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.- Throws:
java.lang.IllegalArgumentException- iflower > upper.
-
-
Method Detail
-
sample
public int sample()
Creates a sample.- Specified by:
samplein interfaceDiscreteSampler- Returns:
- a sample.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classSamplerBase
-
-