> On 19 May 2016, at 02:07, Martin McClure <[email protected]> wrote: > > On 05/18/2016 04:05 PM, Peter Uhnák wrote: >> My questions: >> 1) do we really want to have global fixed seed? > > No! > >> 2) Random new should actually setup a usable seed so I don't need to first >> run it N times before I can use the value > > Yes. > >> 3) Should we switch to what UUIDGenerator is using… reading /dev/urandom for >> the initial seed setup? >> > Yes. > > Though this only works on Unix, so on Windows it uses the current time as a > seed. It might get better results using #microsecondClockValue instead of > #millisecondClockValue. And I'd think about just taking the microsecond value > and sending it #hashMultiply instead of the weird things it's doing now. > (bitXor with the identity hash of the UUIDGenerator instance? That depends on > the randomness of identity hashes, which may or may not be very good.) > It seems likely that Windows has a built-in random number generator, as well, > which would probably be better. > > While we're at it, the class Random is a Park-Miller generator, which has > quite poor randomness by modern standards. Most other Smalltalks have > upgraded -- GemStone uses CMWC (pure Smalltalk, very simple and quite fast; I > wrote that one), VW I believe uses Lagged Fibonacci, and Squeak has moved to > Mersenne Twister last I heard. I've tested all three against statistical > tests of randomness -- generated about 650GB of random bytes from each, ran > them through the tests (which require that much data to get good statistics). > > All three are pretty good, only failing a few tests. The only generator I > tested that passed *all* tests was Linux /dev/urandom. Which is also fast. If > you're on Linux, and don't need a repeatable random sequence, I'd use > /dev/urandom. If you do need to be able to have a repeatable sequence with > good randomness properties, I'd use one of the three generators I mentioned > above. Of the three, the simplest and fastest is CMWC.
Martin, Would you be willing to contribute your implementation to Pharo ? Possibly with some tests ? Sven > Regards, > > -Martin >
