Class RandomEngine
java.lang.Object
random.engine.RandomEngine
- Direct Known Subclasses:
MersenneTwister
Interface for all random numbers generators.
- Author:
- Federico Granata
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMakes this class non instantiable, but still lets others inherit from it. -
Method Summary
Modifier and TypeMethodDescriptionstatic RandomEngineReturns the default engine of uniform random number: the engine is seeded with the current time.abstract doubleReturns a 64 bit uniformly distributed random number in the open unit interval (0.0,1.0) (excluding 0.0 and 1.0).abstract intnextInt()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 longReturns 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 doubleraw()Returns a 32 bit uniformly distributed random number in the open unit interval (0.0,1.0) (excluding 0.0 and 1.0).abstract doubleraw2()Returns a 32 bit uniformly distributed random number in the open unit interval [0.0,1.0) (including 0.0, excluding 1.0).abstract voidsetNewSeed(long seed) Sets the seed of the default engine of uniform random number.
-
Constructor Details
-
RandomEngine
protected RandomEngine()Makes this class non instantiable, but still lets others inherit from it.
-
-
Method Details
-
makeDefault
Returns the default engine of uniform random number: the engine is seeded with the current time. Currently this engine isMersenneTwister. -
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).
-