Class OpenPatricianRandom


  • public class OpenPatricianRandom
    extends java.lang.Object
    Supply some more specific random functions.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2015 Created on May 15, 2015
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Random rnd  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int nextGaussian​(int upperBound)
      Generate a gaussian distributed random number with a mean of upperBound/2 and a variance of upperBound/2.
      int nextSlidingRandomDecreasing​(int upperBound, double startProbability)
      Create a random number in the range [0,upperBound].
      private int nextSlidingRandomRecreasing​(int upperBound, double startProbability, double slope)  
      int nextSlidingRandomSlopeDecreasing​(int upperBound, double slope)
      Create a random number in the range [0,upperBound].
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • rnd

        @Autowired
        private java.util.Random rnd
    • Constructor Detail

      • OpenPatricianRandom

        public OpenPatricianRandom()
    • Method Detail

      • nextGaussian

        public int nextGaussian​(int upperBound)
        Generate a gaussian distributed random number with a mean of upperBound/2 and a variance of upperBound/2. All the values are restricted to the range of [0,upperBound].
        Parameters:
        upperBound - upper bound value.
        Returns:
        random int with gaussion distribution.
        See Also:
        Random.nextGaussian()
      • nextSlidingRandomDecreasing

        public int nextSlidingRandomDecreasing​(int upperBound,
                                               double startProbability)
        Create a random number in the range [0,upperBound]. The startProbability the probability for the value 0. This in turn determines the probabilities for all the other numbers, as the sum of all probabilities in the range [0,upperBound] must sum up to 1 and the change from n to n+1 is linear.
        Parameters:
        upperBound - upper limit
        startProbability - initial probability
        Returns:
        next random integer
      • nextSlidingRandomSlopeDecreasing

        public int nextSlidingRandomSlopeDecreasing​(int upperBound,
                                                    double slope)
        Create a random number in the range [0,upperBound]. The slope defines the linear slope from [0,upperBound+1]. The value at upperBound+1 is 0. This in turn determines the probabilities for all the other numbers, as the sum of all probabilities in the range [0,upperBound] must sum up to 1 and the change from n to n+1 is linear.
        Parameters:
        upperBound - upper limit
        slope - of for the random limit calculation
        Returns:
        next random integer
      • nextSlidingRandomRecreasing

        private int nextSlidingRandomRecreasing​(int upperBound,
                                                double startProbability,
                                                double slope)