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, otherwise UniformRandomProvider.nextInt().

Since:
1.0
  • Constructor Summary

    Constructors 
    Constructor Description
    DiscreteUniformSampler​(UniformRandomProvider rng, int lower, int upper)  
  • Method Summary

    Modifier and Type Method Description
    int sample()
    Creates a sample.
    java.lang.String toString()

    Methods inherited from class org.apache.commons.rng.sampling.distribution.SamplerBase

    nextDouble, nextInt, nextInt, nextLong

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • 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 - if lower > upper.
  • Method Details