Class RandomEngine

java.lang.Object
random.engine.RandomEngine
Direct Known Subclasses:
MersenneTwister

public abstract class RandomEngine extends Object
Interface for all random numbers generators.
Author:
Federico Granata
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Makes this class non instantiable, but still lets others inherit from it.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the default engine of uniform random number: the engine is seeded with the current time.
    abstract double
    Returns a 64 bit uniformly distributed random number in the open unit interval (0.0,1.0) (excluding 0.0 and 1.0).
    abstract int
    Returns a 32 bit uniformly distributed random number in the closed interval [Integer.MIN_VALUE,Integer.MAX_VALUE] (including Integer.MIN_VALUE and Integer.MAX_VALUE)
    abstract long
    Returns a 64 bit uniformly distributed random number in the closed interval [Long.MIN_VALUE,Long.MAX_VALUE] (including Long.MIN_VALUE and Long.MAX_VALUE)
    abstract double
    raw()
    Returns a 32 bit uniformly distributed random number in the open unit interval (0.0,1.0) (excluding 0.0 and 1.0).
    abstract double
    Returns a 32 bit uniformly distributed random number in the open unit interval [0.0,1.0) (including 0.0, excluding 1.0).
    abstract void
    setNewSeed(long seed)
    Sets the seed of the default engine of uniform random number.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RandomEngine

      protected RandomEngine()
      Makes this class non instantiable, but still lets others inherit from it.
  • Method Details

    • makeDefault

      public static RandomEngine makeDefault()
      Returns the default engine of uniform random number: the engine is seeded with the current time. Currently this engine is MersenneTwister.
    • setNewSeed

      public abstract void setNewSeed(long seed)
      Sets the seed of the default engine of uniform random number. WARNING: this method must be called only by the class Simulation and only before starting the simulation, otherwise the engine is seeded using the current time.
    • nextDouble

      public abstract double nextDouble()
      Returns a 64 bit uniformly distributed random number in the open unit interval (0.0,1.0) (excluding 0.0 and 1.0).
    • nextInt

      public abstract int nextInt()
      Returns a 32 bit uniformly distributed random number in the closed interval [Integer.MIN_VALUE,Integer.MAX_VALUE] (including Integer.MIN_VALUE and Integer.MAX_VALUE)
    • nextLong64

      public abstract long nextLong64()
      Returns a 64 bit uniformly distributed random number in the closed interval [Long.MIN_VALUE,Long.MAX_VALUE] (including Long.MIN_VALUE and Long.MAX_VALUE)
    • raw

      public abstract double raw()
      Returns a 32 bit uniformly distributed random number in the open unit interval (0.0,1.0) (excluding 0.0 and 1.0).
    • raw2

      public abstract double raw2()
      Returns a 32 bit uniformly distributed random number in the open unit interval [0.0,1.0) (including 0.0, excluding 1.0).