\ return a random integer in the range [low,hi]:

: rand-range \ low hi -- rand

n:1+ over n:- rand-pcg n:abs

swap n:mod n:+ ;

\ return a random FP number in the range [0,1]

: rand-float \ -- rand

rand-pcg

` 0x7fffffffffffffff float` \ int64 max as fp literal

n:/ n:abs ;

There was a discussion about the incorporation of the "jitter entropy" library in some encryption product, and I thought that it sounded interesting. So for 19.08, in addition to the OS entropy provider, 8th will also add entropy using the "jitter" provider. This helps guard against attacks on the OS entropy provider.This affects theword as well as the various 'cr' word which rely on thePRNG to be actually randomized.Because it's there, I added aword, which directly returns a random value from this "jitter" provider. NOTE: it is much slower than, which is itself much slower than. However,uses the 'Fortuna' PRNG, so it's cryptographically sound; the PCG one is not, and I don't know about the "jit" version.I'm going to add a few 'rand' libraries as well, just because they're useful in many cases:I'm not sure about how good the 'rand-float' is, given the limitations of FP and the small interval. Someone with more FP knowledge is welcome to chime in.I would also like a reasonable way to generate a 'normal' random number, something which takes a mean and a std-deviation, and produces FP numbers which are normally distributed. Ideas for an implementation welcome!