Documentation of 'org.encog.mathutil.randomize.generate.LinearCongruentialRandom' Java class
LinearCongruentialRandom
org.encog.mathutil.randomize.generate

Class LinearCongruentialRandom

  • All Implemented Interfaces:
    GenerateRandom


    public class LinearCongruentialRandom
    extends AbstractBoxMuller
    A Linear Congruential random number generator. A Linear Congruential Generator (LCG) yields a sequence of randomized numbers calculated with a linear equation. The method represents one of the oldest and best-known pseudorandom number generator algorithms. Most programming languages use this technique. http://en.wikipedia.org/wiki/Linear_congruential_generator/ Donald Knuth, The Art of Computer Programming, Volume 3, Section 3.2.1
    • Field Detail

      • DEFAULT_MOD1

        public static final long DEFAULT_MOD1
        First part of default mod.
        See Also:
        Constant Field Values
      • DEFAULT_MOD2

        public static final long DEFAULT_MOD2
        Second part of default mod.
        See Also:
        Constant Field Values
      • MAX_RAND

        public static final long MAX_RAND
        The maximum rand number that the standard GCC based LCG will generate.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LinearCongruentialRandom

        public LinearCongruentialRandom(long theSeed)
        Construct the default LCG. You need only specify a seed.
        Parameters:
        theSeed - The seed to use.
      • LinearCongruentialRandom

        public LinearCongruentialRandom()
        Constructor to use a seed equal to system time.
      • LinearCongruentialRandom

        public LinearCongruentialRandom(long theModulus,
                                        long theMultiplier,
                                        long theIncrement,
                                        long theSeed)
        Create a LCG with the specified modulus, multiplier and increment. Unless you REALLY KNOW WHAT YOU ARE DOING, just use the constructor that just takes a seed. It will set these values to the same as set by the GCC C compiler. Setting these values wrong can create fairly useless random numbers.
        Parameters:
        theModulus - The modulus for the LCG algorithm.
        theMultiplier - The multiplier for the LCG algorithm.
        theIncrement - The increment for the LCG algorithm.
        theSeed - The seed for the LCG algorithm. Using the same seed will give the same random number sequence each time, whether in Java or DotNet.
    • Method Detail

      • getIncrement

        public final long getIncrement()
        Returns:
        The LCG increment.
      • getModulus

        public final long getModulus()
        Returns:
        The LCG modulus.
      • getMultiplier

        public final long getMultiplier()
        Returns:
        The LCG multiplier.
      • getSeed

        public final long getSeed()
        Returns:
        The current seed. Set to a constant to start, thereafter the previously generated random number.
      • nextDouble

        public final double nextDouble()
        Returns:
        The next random number as a double between 0 and 1.
      • nextLong

        public final long nextLong()
        Returns:
        The next random number as a long between 0 and MAX_RAND.
      • nextBoolean

        public boolean nextBoolean()
        Returns:
        The next random boolean.
      • nextFloat

        public float nextFloat()
        Returns:
        The next random floating point.
      • nextInt

        public int nextInt()
        Returns:
        The next random integer.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.