Open cmears opened 9 years ago
Very interesting. It will take me some time before I can look at this. I trust you have found a workaround for what you want to do? If not let me know and I can make some suggestions.
Yes, I've worked around it by creating a PureMT explicitly, putting it in an IORef, passing the IORef where needed and using sampleFrom
directly. The other way might have been a bit neater, but it's not a big problem. I was definitely surprised by the odd behaviour, though!
same problem here
Hello,
This test program works well on Linux but not on Windows. I am using the library the right way?
On Linux I get a random-looking sequence, but on Windows I get big chunks of the same number repeated.
I think the problem is in the instance of MonadRandom:
This seems to call
withSystemRandom
for every random number, which reseeds the generator, and on Windows the current time is used as the seed, so every call within the same second gets the same result. (The documentation forwithSystemRandom
says that it should only be called once per thread or so [https://github.com/bos/mwc-random/blob/master/System/Random/MWC.hs#L423].)