Class LinearDistributionNearbyRandom

  • All Implemented Interfaces:
    NearbyRandom

    public class LinearDistributionNearbyRandom
    extends Object
    implements NearbyRandom
    P(x) = 2/m - 2x/m².

    Cumulative probability: F(x) = x(2m - x)/m².

    Inverse cumulative probability: F(p) = m(1 - (1 - p)^(1/2)).

    • Field Detail

      • sizeMaximum

        protected final int sizeMaximum
    • Constructor Detail

      • LinearDistributionNearbyRandom

        public LinearDistributionNearbyRandom​(int sizeMaximum)
    • Method Detail

      • nextInt

        public int nextInt​(Random random,
                           int nearbySize)
        Specified by:
        nextInt in interface NearbyRandom
        Parameters:
        random - never null
        nearbySize - never negative. The number of available values to select from. Normally this is the size of the value range for a non-chained variable and the size of the value range (= size of the entity list) minus 1 for a chained variable.
        Returns:
        0 <= x < nearbySize