C# Class RandomOps.MersenneTwister

Pseudo-Random Number Generator (PRNG) using the Mersenne Twister algorithm by Makoto Matsumoto and Takuji Nishimura. This implementation is rewritten from their C source-code originally dated 2002/1/26. This PRNG has a very long period of 2^19937-1 (approximately 4.3 x 10^6001), and is hence known as MT19937. This implementation is the 32-bit version. Not thread-safe.
The original C source-code contains the following copyright notice which still holds for this more or less direct translation to the C# language: 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.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
Inheritance: RanUInt32
Mostra file Open project: DanWBR/dwsim3

Public Methods

Method Description
MersenneTwister ( ) : System

Constructs the PRNG-object and seeds the PRNG with the current time of day. This is what you will mostly want to use.

MersenneTwister ( UInt32 seed ) : System

Constructs the PRNG-object using the designated seed. This is useful if you want to repeat experiments with the same sequence of pseudo-random numbers.

Rand ( ) : UInt32

Draw a random number in inclusive range {0, .., RandMax}

Protected Methods

Method Description
Seed ( UInt32 seed ) : void

Seed with an integer.

Method Details

MersenneTwister() public method

Constructs the PRNG-object and seeds the PRNG with the current time of day. This is what you will mostly want to use.
public MersenneTwister ( ) : System
return System

MersenneTwister() public method

Constructs the PRNG-object using the designated seed. This is useful if you want to repeat experiments with the same sequence of pseudo-random numbers.
public MersenneTwister ( UInt32 seed ) : System
seed System.UInt32
return System

Rand() public final method

Draw a random number in inclusive range {0, .., RandMax}
public final Rand ( ) : UInt32
return System.UInt32

Seed() protected final method

Seed with an integer.
protected final Seed ( UInt32 seed ) : void
seed System.UInt32
return void