Class MersenneTwister
- java.lang.Object
-
- nl.tudelft.simulation.jstats.streams.RandomNumberGenerator
-
- nl.tudelft.simulation.jstats.streams.MersenneTwister
-
- All Implemented Interfaces:
Serializable,StreamInterface
public class MersenneTwister extends RandomNumberGenerator
A java implementation of the Mersenne Twister pseudo random number generator.This is a Java version of the C-program for MT19937: Integer version. genrand() generates one pseudorandom unsigned integer (32bit) which is uniformly distributed among 0 to 2^32-1 for each call. sgenrand(seed) set initial values to the working area of 624 words. (seed is any 32-bit integer except for 0).
Orignally Coded by Takuji Nishimura, considering the suggestions by Topher Cooper and Marc Rieffel in July-Aug. 1997. More information can be found at http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/ARTICLES/mt.pdf and https://en.wikipedia.org/wiki/Mersenne_Twister.
Copyright (c) 2002-2023 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.
- Author:
- Alexander Verbraeck, Peter Jacobs
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class nl.tudelft.simulation.jstats.streams.RandomNumberGenerator
seed
-
-
Constructor Summary
Constructors Constructor Description MersenneTwister()constructs a new Mersenne Twister.MersenneTwister(long seed)Constructor using a given seed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longnext(int bits)returns the next value in the stream.voidsetSeed(long seed)Set the seed of the generator.-
Methods inherited from class nl.tudelft.simulation.jstats.streams.RandomNumberGenerator
getOriginalSeed, getSeed, nextBoolean, nextDouble, nextFloat, nextInt, nextInt, nextLong, reset, restoreState, saveState, toString
-
-
-
-
Method Detail
-
next
public long next(int bits)
returns the next value in the stream.- Specified by:
nextin classRandomNumberGenerator- Parameters:
bits- int; the number of bits used- Returns:
- the next value.
-
setSeed
public void setSeed(long seed)
Set the seed of the generator.- Specified by:
setSeedin interfaceStreamInterface- Specified by:
setSeedin classRandomNumberGenerator- Parameters:
seed- long; the new seed
-
-