Nice! Have you heard of PCG? Technically a bit "more random" (not really sure under which circumstances where data viz people need a prng that actually matters, but still) while still being pretty fast
https://www.pcg-random.org/download.html
I'm giving it a shot, but it requires manually implementing 64-bit integer arithmetic and that's more of a hassle than I thought. Fun thought-exercise though :p
Well I tried shortening your code Job, but it turns out that in Safari, your version is twice as fast (in Firefox/Chrome, the version that does less arithmetic is faster). Feel free to play around with it https://observablehq.com/@jrus/permuted-congruential-generator
Very nice! And somewhat surprising result as well, given that I'm on Linux and use Firefox - I wasn't optimizing for Safari.
Surely there's a fastest-on-all-three option hidden in there somewhere ;)
I'm trying various approaches here https://observablehq.com/d/b1aa7c52fc50a054
On Chrome, using a Float32Array(1) to store s is twice faster than having it in a normal variable.
On Safari Jacob’s code with &0xFFFF is much much faster (but it returns a signed number, out of the spec).
It's a fun game
For whatever reason, in Safari `& 0xFFFFFFFF` is a whole lot faster than `>>> 0` when you do it to arbitrary numbers. I think the compiler can do better type specialization that way. Once you already have a 32-bit (signed) number, >>> 0 to make it unsigned is also very fast.