Class UniformLongSampler.SmallRangeUniformLongSampler

java.lang.Object
org.apache.commons.rng.sampling.distribution.UniformLongSampler
org.apache.commons.rng.sampling.distribution.UniformLongSampler.SmallRangeUniformLongSampler
All Implemented Interfaces:
LongSampler, SharedStateLongSampler, SharedStateSampler<SharedStateLongSampler>
Enclosing class:
UniformLongSampler

private static final class UniformLongSampler.SmallRangeUniformLongSampler extends UniformLongSampler
Discrete uniform distribution sampler when the range is small enough to fit in a positive long. This sampler assumes the lower bound of the range is 0 and the range is non-zero.
  • Field Details

    • n

      private final long n
      Maximum range of the sample (exclusive).
    • limit

      private final long limit
      Limit of the uniform range (inclusive) to sample a positive long. This is the largest positive multiple of n minus 1: floor(2^63 / n) * n - 1. The -1 changes the limit to an inclusive bound and allows support for a power of 2 range.
  • Constructor Details

    • SmallRangeUniformLongSampler

      SmallRangeUniformLongSampler(UniformRandomProvider rng, long range)
      Parameters:
      rng - Generator of uniformly distributed random numbers.
      range - Maximum range of the sample (exclusive).
    • SmallRangeUniformLongSampler

      Parameters:
      rng - Generator of uniformly distributed random numbers.
      source - Source to copy.
  • Method Details