Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the default seed of `mt19937` 5489?

According to the Standard, the value of mt19937::default_seed is 5489u:

static constexpr result_type default_seed = 5489u;

This seems very artificial.

Is there any (mathematical or theoretical) reason behind this?

like image 962
ynn Avatar asked Nov 30 '25 01:11

ynn


1 Answers

C++'s Mersenne Twister uses 5489 as the default seed value because of the many, many implementations which used it before. That is, it's a tradition. Just as one example which predates the C++ implementation by a long time, Matlab also uses 5489.

So it would be inconsistent to use 0 or 1, because those are not values used by other popular Mersenne Twister implementations.

There have been other values like 4357 used before 5489, see this thread for some details and links to those historical default seeds: https://sourceware.org/legacy-ml/gsl-discuss/2006-q4/msg00014.html

5489 may have first been used in 2002, by this implementation from Nishimura and Matsumoto: http://www.math.sci.hiroshima-u.ac.jp/m-mat/MT/MT2002/CODES/mt19937ar.c

Finally, note that some simple integer seeds like these can put the Mersenne Twister into a relatively low entropy initial sequence. I speculate that someone noticed (between 1998 and 2002) that 4357 caused such a problem and 5489 appeared to give better results.

like image 133
John Zwinck Avatar answered Dec 01 '25 13:12

John Zwinck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!