Class MersenneTwister

java.lang.Object
random.engine.RandomEngine
random.engine.MersenneTwister

public class MersenneTwister extends RandomEngine
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

Author:
(translated in java by) Federico Granata
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of Prova
    MersenneTwister(long seed)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns a 64 bit uniformly distributed random number in the open unit interval [0.0,1.0) (including 0.0 and excluding 1.0).
    int
    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)
    long
    Returns a 32 bit uniformly distributed random number in the closed interval [0,4294967295] (including 0 and 4294967295)
    long
    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)
    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).
    double
    Returns a 32 bit uniformly distributed random number in the open unit interval [0.0,1.0) (including 0.0, excluding 1.0).
    void
    setNewSeed(long seed)
    Sets the seed of the default engine of uniform random number.
    static void
    test

    Methods inherited from class RandomEngine

    makeDefault

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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: RandomEngine
      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.
      Specified by:
      setNewSeed in class RandomEngine
    • 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:
      nextDouble in class RandomEngine
    • 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:
      nextInt in class RandomEngine
    • 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:
      nextLong64 in class RandomEngine
    • 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:
      raw in class RandomEngine
    • 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:
      raw2 in class RandomEngine
    • test

      public static void test()
      test