Replace arc4random in numpy with... KISS / Mersenne?
The use of arc4random in numpy was the only thing forcing us to include libbsd and with it libmd to get arc4random on other platforms (Linux). libbsd / libmd are hard to build and it was decided to remove these libs. Consequently arc4random was replaced with the measly standard rand().
Should we do something better? I noticed bsdnt includes random functions:
- KISS / SuperKISS / Mersenne_twister pseudorandom number generators
- see https://github.com/wbhart/bsdnt/tree/master/rand
@sydow what do you think? could it be of use?
I suggest that we use either xoshiro256++ or xoshiro256** from https://prng.di.unimi.it/. This seems to be state of the art in non-crypto PRNG's. They are extremely fast, very easy to program (and public domain implementations are provided) and they pass all common test suites for randomness quality. They are both faster and better than the ones provided by BSDNT.
The only diificulty is to choose one of these two; the authors do not give clear recommendations...
xoshiro256 is already in zigs standard library, so perhaps this can be our first stab at using zig stuff? This way we avoid introducing yet another C library dependency.
In Zig, I think one has to explicitly state that a function should follow C calling conventions for it to be callable from C, as I doubt the zig std lib rand force that, we would need some intermediate functions. I can take a look at how we can introduce zig in our build chain...
This sounds fine. When you get this to work we need another layer on top, to produce psedudorandom integers in a given range, maybe the same for floating point etc.