I’m relatively new to the world of simulation and am running some discrete event simulations using SimJulia.jl and Distributions.jl for a graduate-level class. I noticed that the Wikipedia article for Mersenne Twister (which Julia uses under the hood for PRNG mentions that there are issues with independence if using multiple instances differing only in seed value. There’s also a paper on an approach to solving the problem, but I haven’t yet read it in depth.
Is there a canned Julia solution to generating random numbers in parallel so that multiple simulation replications are independent? If I’m running simulations in parallel using multithreading and just have all draw from GLOBAL_RNG, is that sufficient?
Good to know that rand isn’t currently thread-safe. I’m also looking on advice for dealing with (from Wikipedia):
Multiple instances that differ only in seed value (but not other parameters) are not generally appropriate for Monte-Carlo simulations that require independent random number generators, though there exists a method for choosing multiple sets of parameter values. [40][41]
use the randjump function from the Future module.
However, if you use Mersenne Twister the risk of collision, due to birthday paradox, of simply using different (possibly randomized) seeds is very low due to its long period.
A secondary question as a point of curiousity: does anyone know why randjump lives in Future instead of in Random? As far as I can tell, there’s been no randjump function outside of Future available in any Julia 1.x series release.
RandomNumbers.jl includes several generators designed to allow multiple simultaneous streams like PCG and Random123. They aren’t the fastest, but each can combine a seed with an “id” for each stream. I haven’t used the Julia interface/implementations of them yet, but I assume they expose similar functionality.