Class MarsagliaTsangWangDiscreteSampler.MarsagliaTsangWangBase64Int16DiscreteSampler

    • Field Detail

      • MASK

        private static final int MASK
        The mask to convert a byte to an unsigned 16-bit integer.
        See Also:
        Constant Field Values
      • t1

        private final int t1
        Limit for look-up table 1.
      • t2

        private final int t2
        Limit for look-up table 2.
      • t3

        private final int t3
        Limit for look-up table 3.
      • t4

        private final int t4
        Limit for look-up table 4.
      • table1

        private final short[] table1
        Look-up table table1.
      • table2

        private final short[] table2
        Look-up table table2.
      • table3

        private final short[] table3
        Look-up table table3.
      • table4

        private final short[] table4
        Look-up table table4.
      • table5

        private final short[] table5
        Look-up table table5.
    • Constructor Detail

      • MarsagliaTsangWangBase64Int16DiscreteSampler

        MarsagliaTsangWangBase64Int16DiscreteSampler​(UniformRandomProvider rng,
                                                     java.lang.String distributionName,
                                                     int[] prob,
                                                     int offset)
        Parameters:
        rng - Generator of uniformly distributed random numbers.
        distributionName - Distribution name.
        prob - The probabilities.
        offset - The offset (must be positive).
    • Method Detail

      • fill

        private static int fill​(short[] table,
                                int from,
                                int to,
                                short value)
        Fill the table with the value.
        Parameters:
        table - Table.
        from - Lower bound index (inclusive)
        to - Upper bound index (exclusive)
        value - Value.
        Returns:
        the upper bound index
      • 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