If the solution with a custom random number generator presented in Extract RNG seed in julia is not practical for you, so I could come up with to copy the entire structure of the global random number generator:
function reset_global_rng(rng_state) Base.Random.GLOBAL_RNG.seed = rng_state.seed Base.Random.GLOBAL_RNG.state = rng_state.state Base.Random.GLOBAL_RNG.vals = rng_state.vals Base.Random.GLOBAL_RNG.idx = rng_state.idx end rs = deepcopy(Base.Random.GLOBAL_RNG) println(rand(5))
although I'm not 100% sure how it does not interact with dsfmt_gv_srand() in random.jl.
source share