RandomSingleton

public class RandomSingleton

Creates only one instance of the random number generator that can be used throughout the whole model. Simulation results can then be reproduced by using the same seed.

Author:Milan Lovric

Methods

getInstance

public static RandomSingleton getInstance()

Getter for the singleton instance of the random number generator.

Returns:Random number generator.

nextDouble

public double nextDouble()

Generates a pseudorandom real number between 0 and 1.

Returns:Pseudorandom real double.

nextInt

public int nextInt(int bound)

Generates a pseudorandom whole number smallet than the bound.

Parameters:
  • bound – Upper bound.
Returns:

Pseudorandom whole number.

setSeed

public void setSeed(long seed)

Setter method for the seed of the random number generator.

Parameters:
  • seed – Seed of the random number generator.