Class DiscreteUniformSampler.PowerOf2RangeDiscreteUniformSampler

    • Field Detail

      • shift

        private final int shift
        Bit shift to apply to the integer sample.
    • Constructor Detail

      • PowerOf2RangeDiscreteUniformSampler

        PowerOf2RangeDiscreteUniformSampler​(UniformRandomProvider rng,
                                            int 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.
    • 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