about summary refs log tree commit diff

Mersenne Twister

(readme mostly ripped straight from another projects notes about it's implementation of mt19937. That's also where I ripped the lib.rs file from. i just wanted to use it in another project so i thought i was extract it. this is a port and not using a crate from crates.io because i thought it would be fun and thrilling. i was right)

https://en.wikipedia.org/wiki/Mersenne_Twister

I've been doing research on Mersenne Twister. Apparently if you seed it poorly, a "bad seed", with a run of lots of 1s of 0s, you can get into a bad state that can take a long time to recover (citation needed).

This S.O. answer about seeding Mersenne mentions there are other PRNGs that are easier to implement. https://stackoverflow.com/a/8473025

Checked against the (original?) Mersenne Twister website.
https://www.math.sci.hiroshima-u.ac.jp/m-mat/MT/emt.html
It has the latest version of the algorithm up at
https://www.math.sci.hiroshima-u.ac.jp/m-mat/MT/MT2002/emt19937ar.html
which has output that we can test against here
https://www.math.sci.hiroshima-u.ac.jp/m-mat/MT/MT2002/CODES/mt19937ar.out
and it all matches! both the u32 generator and the double "real" (f64) generator.

License:
From the license page for MT.

Until 2001/4/6, MT had been distributed under GNU Public License, but after 2001/4/6, we decided to let MT be used for any purpose, including commercial use. 2002-versions mt19937ar.c, mt19937ar-cok.c are considered to be usable freely.

Given that seeming dedication to the public domain, this is in turn rightly licensed as such. If that does not work for you, there is a LICENSE file with Creative Commons Zero, too, that I stuck in the repo. Can I do that? Iunno, I'm not a lawyer. I think probably, yes, since it seems to be dedicated to the public domain, anyway.