Questions tagged [mersenne-twister]

The Mersenne Twister is a pseudo-random number generator (PRNG) suitable for Monte-Carlo simulations. It has a long period (2^19937-1) and yet takes very little memory space.

Mersenne Twister(MT) is a pseudorandom number generating algorithm developed by Makoto Matsumoto and Takuji Nishimura in 1996/1997. An improvement on initialization was given in 2002

It has a far longer period and far higher order of equidistribution than any other implemented generators. (It is proved that the period is 2^19937-1, and 623-dimensional equidistribution property is assured.)

Fast generation. (Although it depends on the system, it is reported that MT is sometimes faster than the standard ANSI-C library in a system with pipeline and cache memory.) (Note added in 2004/3: on 1998, usually MT was much faster than rand(), but the algorithm for rand() has been substituted, and now there is not much difference in speed on most platforms.)

Efficient use of the memory. (The implemented C-code mt19937.c consumes only 624 words of working area.)

Source code and documentation for the basic algorithm along with several variations can be found here: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html

165 questions
0
votes
3 answers

Duplicate values generated by mt19937

I am working with C++11's random library, and I have a small program that generates a coordinate pair x, y on a circle with unit radius. Here is the simple multithreaded program #include #include #include using…
BillyJean
  • 1,537
  • 1
  • 22
  • 39
0
votes
2 answers

Mersenne Twister random algorithm how can i seed init_genrand, random numbers are always the same C#

I'm using A C-program for MT19937, with initialization improved 2002/1/26.Coded by Takuji Nishimura and Makoto Matsumoto. taken from Codeproject link when after copying the source files and ran the random functions, i always get the same numbers. In…
Liad Livnat
  • 7,435
  • 16
  • 60
  • 98
0
votes
3 answers

recasting a unsigned char array to an unsigned long array

Ok, I'm using a raw SHA1 hash to seed a Mersenne Twister pseudo-random number generator the generator gives me the option to seed either with an unsigned long or a array of unsigned longs the SHA1 class I'm using gives me the hash as a 20 byte array…
Ryex
  • 337
  • 3
  • 12
0
votes
1 answer

MTRand produces an error on compilation

I am using MTRand (the Mersenne Twister random number generator from http://www.bedaux.net/mtrand/) inside a class that I have defined. And when I try to compile I get an unexpected error that I can't decode. I'm a novice c++ programmer, so any help…
Y.P.
  • 3
  • 2
0
votes
2 answers

using dSFMT for random float (0,1)

This project is in Obj-C for iphone. I'm using the double float version of sfmt available here: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/#dSFMT After seeding dsmft with the current time, I'm calling: r = dsfmt_gv_genrand_close_open() to…
James Hunt
  • 15
  • 4
0
votes
1 answer

Mersenne Twister seed has no effect

So I've got a custom randomizer class that uses a Mersenne Twister (the code I use is adapted from this site). All seemed to be working well, until I started testing different seeds (I normally use 42 as a seed, to ensure that each time I run my…
GarrickW
  • 2,181
  • 5
  • 31
  • 38
-1
votes
1 answer

Effective period of Mersenne Twister generator output

Mersenne Twister generator has a period of (2^19937)-1, but it is period of internal states. Any idea what is the effective period of MT 32 bit output - period over which 32 bit output does not repeat. It has to be smaller than (2^31)-1 but I…
mesibo
  • 3,970
  • 6
  • 25
  • 43
-1
votes
1 answer

Performance issue with random double generation using Mersenne twister

I have the following code: //#include all necessary things class RandomGenerator { public: double GetRandomDbl() { random_device rd; mt19937 eng(rd()); std::uniform_real_distribution dDistribution(0,1); return…
-1
votes
1 answer

randomly generate unique integers C++

I wrote a simple program for League that generates a random role (AP, AD, Hybrid, Tank), lane, and champion. You can see the code here: #include #include #include #include using namespace std; int main() { …
Riggs
  • 11
  • 2
-1
votes
2 answers

Error with min/max arguments of uniform_real_distribution c++

I have a function to generate a (pseudo) random walk on a square lattice where the walk should not breach the boundaries of this square, full function below: /** * @brief Performs a single random walk returning the final distance from the origin * *…
sjrowlinson
  • 3,297
  • 1
  • 18
  • 35
-1
votes
1 answer

Can't convert uniform_int_distribution to int

I'm trying to make random level generator that uses mersenne twister. Here's the code (it's just beginning, so it doesn't make much sense): Generator.h: //Level generator #pragma once class GameMap { public: static int bgmap[256][256]; …
-1
votes
2 answers

Explination of Mersenne Twister algorithm

I am looking to implement the Mersenne Twister random number generator in a project. However, since this is for an embedded application, I will be later optimizing the code for my architecture. However, I can find little documentation on how the…
audiFanatic
  • 2,296
  • 8
  • 40
  • 56
-1
votes
2 answers

Implementation of a Stream cipher in c

I want to implement the following function: I am using the Mersenne-Twister-Algorithm (from Wikipedia) as my pseudorandom number generator. It is a stream cipher The pseudocode is: encrypted text = CLEARTEXT XOR STREAM; the 'stream' is defined as…
Kossi
  • 21
  • 1
  • 4
-2
votes
1 answer

Random number generation in python for Kernighan–Lin and Simulated annealing algorithm?

Is it a good idea (In terms of quality of the number generated and CPU time required) to use Python's(2.7) default(Mersenne Twister) random() function as the random number generator for Kernighan–Lin algorithm? Is there some better way to do…
-4
votes
1 answer

What is the range of the Mersenne Twister in Java?

I have the following program: import java.util.*; import cern.jet.random.engine.MersenneTwister; import cern.jet.random.engine.RandomEngine; public class printy{ static RandomEngine val = new MersenneTwister( (int)System.currentTimeMillis()…
ShanZhengYang
  • 16,511
  • 49
  • 132
  • 234
1 2 3
10
11