Exploring Randomness in JavaScript
bennadel.com
bennadel.com
Still, if you want consistent quality and speed across all browsers current and future, you're better off bundling your own PRNG code. That's also necessary if you want a repeatable sequence from a specific seed value, neither of the browser built-in methods support that.
And finally I tried to make a nicer Dieharder wrapper and a simple PRNG library, but lord knows how relevant it is anymore: https://github.com/blixt/js-arbit
I guess in this archaeological dig I also found how many useful resources on the internet disappear in less than a decade.
[1]: https://web.archive.org/web/20120502223108/http://baagoe.com... (Baagøe's original site is down)
[2]: https://rurban.github.io/dieharder/ (old site is dead, though here's a web archive link: https://web.archive.org/web/20170609075452/http://www.phy.du...)
[3]: https://gist.github.com/blixt/f17b47c62508be59987b (Don't use this)
[4]: https://github.com/nquinlan/better-random-numbers-for-javasc... (this is mainly a mirror of Baagøe's wiki)
function random() {
random._s = random._s || 11224; // seed
return (random._s = random._s * 16807 % 2147483647) / 2147483646;
}
Wikipedia says this approach has been around at least since the 1950s.