Class DiscreteUniformSampler.SmallRangeDiscreteUniformSampler

    • Field Detail

      • n

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

        private final long threshold
        The level below which samples are rejected based on the fraction remainder.

        Any remainder below this denotes that there are still floor(2^32 / n) more observations of this sample from the interval [0, 2^32), where n is the range.

    • Constructor Detail

      • SmallRangeDiscreteUniformSampler

        SmallRangeDiscreteUniformSampler​(UniformRandomProvider rng,
                                         int range)
        Parameters:
        rng - Generator of uniformly distributed random numbers.
        range - Maximum range of the sample (exclusive).
    • Method Detail

      • sample

        public int sample()
        Description copied from interface: DiscreteSampler
        Creates an int sample.
        Returns:
        a sample.
      • withUniformRandomProvider

        public SharedStateDiscreteSampler withUniformRandomProvider​(UniformRandomProvider rng)
        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