Class MersenneTwister
- All Implemented Interfaces:
Serializable
,StreamInterface
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-2024 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:
-
Field Summary
Fields inherited from class nl.tudelft.simulation.jstats.streams.RandomNumberGenerator
seed
-
Constructor Summary
ConstructorDescriptionconstructs a new Mersenne Twister.MersenneTwister
(long seed) Constructor using a given seed. -
Method Summary
Methods inherited from class nl.tudelft.simulation.jstats.streams.RandomNumberGenerator
getOriginalSeed, getSeed, nextBoolean, nextDouble, nextFloat, nextInt, nextInt, nextLong, reset, restoreState, saveState, toString
-
Constructor Details
-
MersenneTwister
public MersenneTwister()constructs a new Mersenne Twister.System.currentTimeMillis()
is used as seed value. -
MersenneTwister
public MersenneTwister(long seed) Constructor using a given seed.- Parameters:
seed
- long; The initial seed.
-
-
Method Details
-
next
public long next(int bits) returns the next value in the stream.- Specified by:
next
in 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:
setSeed
in interfaceStreamInterface
- Specified by:
setSeed
in classRandomNumberGenerator
- Parameters:
seed
- long; the new seed
-