Krzysztof Szewczyk

Mersenne twister


Mersenne Twister is the most popular pseudorandom generator in current use. This is implied by a few properties of mersenne twister, making it suitable for larger range of applications.

If you don't exactly need good quality of random numbers, you can without doubt perform a simple linear random number generation, a very fast way of creating poor quality random numbers that tend to be repetitive over time if coefficients are chosen incorrectly.

If you need very good quality of random numbers, you could get a camera looking on a lavalamp, a radio receiver receiving data from certain unoccupied, secret frequency (it's a good idea to receive on the smallest spectrum, therefore the random number generation is unbiasable), or safer pseudorandom number generator seeded from said source.


Mersenne Twister is quite fast with it's small spinning-up buffer (that is 624 bytes long - it's a mersenne prime). The generator is quite fast too, because once spinned up, it's generating random numbers in quite decent speed.

This little "flaw" in mersenne twister (small spin-up buffer designed to speed up the pseudorandom number generator), makes the generator completely predictable to guess the output, given only the first 624 numbers given. Matsumoto thought about tempering function, making it harder (or impossible) to reverse. His plan failed, and mathematicans started untempering the twister effectively reversing its internal state given his primary output.

My work on Mersenne Twister wouldn't be possible without these people and their amazing discoveries. Reversing the state of mersenne twister can be instant (by search depth; the density index) equal to DM=1 and DM=2. I've tried bruteforcing programs with DM=3 (a few seconds), DM=4 (from 2 minutes to half an hour), DM=5 (for a few days, around 2 usually). I haven't tried DM=6 by now, because it would take insane amount of time, significantly longer than my lifespan.

I've golfed a few Seed programs, some of them worked flawlessly, I've golfed a few of them. I found it a pretty neat experience to work with Seed, but I'm abadoning it for quite some time, because golfing programs requires enormous amount of processing power.


I'll keep on gluing together bits and bobs with inefficient Seed programs. I probably will keep on doing this stuff for some time more. I can't see a good use with the knowledge I got, but I really appreciate it for having a cool time.