I would like to implement mersenne twister for my simulation : I have different abjects and I want to have a different seeds for each of them. I would like to check the uniformity in this work.
Thank you for your reply.
I am wondering, A1(10) 10 is the seed?
Sorry I am qite new in C++ and how is the seed generate?
I am wondering if you can help me.
thanks for your answers, but if I use the warm-up then how can I have a different seeds, my simulation should have a different seeds indeed.?
could please specify for me how to keep both (uniformity - different seeds ) n my work?
Also when I run the code I got this error, I run in ubuntu with g++
ameneh@ameneh:~/mtrand$ g++ -std=c++0x ami.cpp -o s
ami.cpp:16:14: error: expected initializer before ‘initialize_twister’
Thanks for your help, I have questions,
std::minstd_rand lcg(seed) in this part lcg is generate the seeds? could you please explain to me what is lcg, is it the liner random number or something else?
This inexpensive lcg is used to generate the predictable (repeatable) seed sequence from the single seed that it has been fed. That seed sequence is used for the initial warm-up of the twister.
Yes I agree, why in the code dicard the NDISCARDafter geeting the seed? twister.discard(NDISCARD)
I would like to understand the logic behind the warm up.
I am really appreciate your answer.
then the other generator is also can be use for prepare the seed ?
static std::random_device rand_dev ; in this line the random_device is also preparing the seed then what is the different between these two parts?
thanks in advance
> I would like to understand the logic behind the warm up.
When certain seeds are used (seeds with low entropy, typically those with long runs of zero or one bits), shift-register-based pseudo random number generators (like the Mersenne Twister) tend to generate an initial sequence with poor randomness attributes. The internal state of std::mt19937 consists of std::mt19937::state_size (624 IIRC) numbers, and the idea of warm-up is to exercise the engine long enough (by generating and discarding numbers) till this state becomes sufficiently statistically random (without underlying bit patterns). As a rough rule, the longer the period of the engine, the more should be the length of the initial warm-up sequence.
The generating function for std::seed_seq is the defaukt Mersenne Twister warm-up sequence; so the extra warm-up of discarding some number of values (NDISCARD) before using the engine is probably unnecessary for strictly conforming implementations.
> in this line the random_device is also preparing the seed then what is the different between these two parts?
The random_device is generating a seed if and only if a seed value is not provided (when constructing the object).
If a seed value is provided, that seed is used (generate a repeatable quasi-random sequence).