Suppose I've the following generator which I seeded with a number X
std::mt19937 gen(X);
I thought I could simply use gen() to know which seed I've used (i.e. X) or, in general, if I don't seed the generator, which default seed has been used, but it seemed to return a different seed than X. Is it possible? Why? Or maybe I simply did a mistake?
I've no experience on how to create or, simply, how a pseudo-random number generator really works under the hood (I should inform myself).
My question is: if I use the same seed, am I assured that I will always have the same sequence in the same order, or am I assured only that the output numbers will be the same but possibly in different orders?
I know that a sequence usually means that order counts, otherwise it would be called a set, but I just want to make sure.
> if I use the same seed, am I assured that I will always have the same sequence in the same order
Yes.
1 2 3 4
// rng_a, rng_b and rng_c will generate the same sequence of numbers
std::mt19937 rng_a ; // default constructed (the IS specifies that the default seed is 5489U)
std::mt19937 rng_b( 5489U ) ; // constructed with seed 5489U
std::mt19937 rng_c( 5489U ) ; // constructed with same seed as rng_b