For questions related to the Mersenne Twister pseudorandom number generator with a period of 2^19337
Questions tagged [mt19937]
39 questions
0
votes
1 answer
How to seed mt19937 once per app in C++ and use it multiple times?
I can get the mt19937 rng seeded in a simple app. Now I am trying to get it seeded once per app and use it multiple times whenever it's needed. Here is my code. The error I'm getting is in GenerateRandomNumber - "gen: undeclared identifier".…

JeffR
- 765
- 2
- 8
- 23
0
votes
0 answers
Is std::random_device limited on number of instances on g++?
This codeblock
try
{
for(int i=0;i tmp=std::shared_ptr(new std::random_device);
rdThread.push_back(tmp);
…

huseyin tugrul buyukisik
- 11,469
- 4
- 45
- 97
0
votes
1 answer
How to save/retrieve mt19937 so that the sequence is repeated?
Here is my attempt
using namespace std;
int main()
{
mt19937 mt(time(0));
cout << mt() << endl;
cout << "----" << endl;
std::ofstream ofs;
ofs.open("/path/save", ios_base::app | ifstream::binary);
ofs << mt;
…

Remi.b
- 17,389
- 28
- 87
- 168
0
votes
1 answer
mt19937 and normal distribution
Helo there!
I am just starting to code in C++ and I'm not sure how to use random numbers generators properly. For example I need numbers from range [0,30000], how to make sure that I won't get only small numbers from my range.
My…

ogarogar
- 323
- 2
- 14
0
votes
1 answer
random number invocation from boost toolkit
Attempting to use the Boost toolkit on Windows 7, Vis Studio 2013.
I've successfully run their example here
There's a set of lines in the code:
// This is a typedef for a random number generator.
// Try boost::mt19937 or boost::ecuyer1988 instead of…

elbillaf
- 1,952
- 10
- 37
- 73
0
votes
1 answer
Reproduce the same result of the C++ 11 random generator
Is it guaranteed by the standard that if std::mt19937 was seeded by the same number, it will produce the same sequence of numbers on all platforms?
In other words, is its implementation well-defined by the standard or it is like std::rand() which…

Humam Helfawi
- 19,566
- 15
- 85
- 160
-1
votes
2 answers
How can I create pseudo-random numbers depending on multiple integer parameters?
My overall goal is to create a round-based game. So, I need some seemingly randomly generated numbers, example in fights - but not only, there are some different occasions. Anyway, I want those numbers to be reliably the same if certain parameters…

truberfighter
- 3
- 2
-1
votes
1 answer
How to Generate 32 bit integers random number using marsenne twister Algorithm
How to Generate 32 bit integers random number using marsenne twister Algorithm? And save it to binary file.

Ari Pili
- 21
- 1
-1
votes
1 answer
mt19937 can't set random_device
My code is failing as to not recognize "generator", but I declare it at the top of my C++ file. I need it to be thread-safe, so I declared it with "thread_local":
#include
#include
#include
using namespace…

JeffR
- 765
- 2
- 8
- 23