Class RandomFactory


  • public class RandomFactory
    extends java.lang.Object
    RandomFactory is responsible for creating Random generator objects. It does not provide individual random numbers, but will create a random generator; either using a fixed seed or random seeded (default).

    The seed can be globally predefined using -Delki.seed=123.

    These classes are not optimized for non-predictability, but for speed, as scientific experiments are not likely to be adversarial.

    Since:
    0.5.5
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static RandomFactory DEFAULT
      Global default factory
      protected long seed
      Seed.
    • Constructor Summary

      Constructors 
      Constructor Description
      RandomFactory​(long seed)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static RandomFactory get​(java.lang.Long seed)
      Factory method: Get a random factory for the given seed.
      private static long getGlobalSeed()
      Initialize the default random.
      java.util.Random getRandom()
      Get a random generator.
      java.util.Random getSingleThreadedRandom()
      Get a non-threadsafe random generator.
      static int murmurMix32​(int h)
      MurmurHash3 mixing function.
      static long murmurMix64​(long k)
      MurmurHash3 mixing function.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • DEFAULT

        public static final RandomFactory DEFAULT
        Global default factory
      • seed

        protected long seed
        Seed.
    • Constructor Detail

      • RandomFactory

        public RandomFactory​(long seed)
        Constructor.
        Parameters:
        seed - Random seed
    • Method Detail

      • getGlobalSeed

        private static long getGlobalSeed()
        Initialize the default random.
        Returns:
        seed for the random generator factory.
      • get

        public static RandomFactory get​(java.lang.Long seed)
        Factory method: Get a random factory for the given seed.
        Parameters:
        seed - Seed
        Returns:
        Instance
      • getRandom

        public java.util.Random getRandom()
        Get a random generator.
        Returns:
        Random generator
      • getSingleThreadedRandom

        public java.util.Random getSingleThreadedRandom()
        Get a non-threadsafe random generator.
        Returns:
        Random generator
      • murmurMix32

        public static int murmurMix32​(int h)
        MurmurHash3 mixing function.
        Parameters:
        h - input
        Returns:
        Output
      • murmurMix64

        public static long murmurMix64​(long k)
        MurmurHash3 mixing function.
        Parameters:
        k - input
        Returns:
        Output
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object