Class MersenneTwister
java.lang.Object
random.engine.RandomEngine
random.engine.MersenneTwister
This is a Java version of the Mersenne Twister.
Coded by Takuji Nishimura and Makoto Matsu.
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above Copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above Copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Any feedback is very welcome.
http://www.math.keio.ac.jp/matumoto/emt.html
email: matumoto@math.keio.ac.jp
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above Copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above Copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Any feedback is very welcome.
http://www.math.keio.ac.jp/matumoto/emt.html
email: matumoto@math.keio.ac.jp
- Author:
- (translated in java by) Federico Granata
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns a 64 bit uniformly distributed random number in the open unit interval [0.0,1.0) (including 0.0 and excluding 1.0).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)longnextLong()Returns a 32 bit uniformly distributed random number in the closed interval [0,4294967295] (including 0 and 4294967295)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)doubleraw()Returns a 32 bit uniformly distributed random number in the open unit interval (0.0,1.0) (excluding 0.0 and 1.0).doubleraw2()Returns a 32 bit uniformly distributed random number in the open unit interval [0.0,1.0) (including 0.0, excluding 1.0).voidsetNewSeed(long seed) Sets the seed of the default engine of uniform random number.static voidtest()testMethods inherited from class RandomEngine
makeDefault
-
Field Details
-
DEFAULT_SEED
public static final int DEFAULT_SEED- See Also:
-
-
Constructor Details
-
MersenneTwister
public MersenneTwister()Creates a new instance of Prova -
MersenneTwister
public MersenneTwister(long seed) Constructor- Parameters:
seed- seed used to generate the sequence
-
-
Method Details
-
setNewSeed
public void setNewSeed(long seed) Description copied from class:RandomEngineSets 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.- Specified by:
setNewSeedin classRandomEngine
-
nextDouble
public double nextDouble()Returns a 64 bit uniformly distributed random number in the open unit interval [0.0,1.0) (including 0.0 and excluding 1.0).- Specified by:
nextDoublein classRandomEngine
-
nextInt
public 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)- Specified by:
nextIntin classRandomEngine
-
nextLong
public long nextLong()Returns a 32 bit uniformly distributed random number in the closed interval [0,4294967295] (including 0 and 4294967295) -
nextLong64
public 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)- Specified by:
nextLong64in classRandomEngine
-
raw
public 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).- Specified by:
rawin classRandomEngine
-
raw2
public 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).- Specified by:
raw2in classRandomEngine
-
test
public static void test()test
-