JuliaRandom / JuliaRandom/RandomNumbers.jl

Question on RNGs for use in parallel simulations

Offen
#37 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Julia
Sterne
100
Forks
23
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

This is a question rather than an issue. I hope that's OK to ask here.

I would like to use a RNG for parallel simulations, and so want statistically independent RNGs for each worker process.

For `Base.Random.MersenneTwister`, I use something like this:
```
rng = Base.Random.MersenneTwister(0)
rngseed = Base.Random.make_seed()
srand(rng, rngseed)

rngs = randjump(rng, numtrials)

f(trial, rng) = ...
pmap(f, 1:numtrials, rngs)
```

I would like to use a RNG from the `Random123` family.
Is this a good choice for parallel sims?

My code would be something like:
```
rng = RandomNumbers.Random123.Threefry4x()
rngseed = RandomNumbers.gen_seed(rng)
srand(rng, rngseed)

rngs = Vector{typeof(rng)}(numtrials)
for trial = 1:numtrials
rngs[trial] = copy(rng)
RandomNumbers.Random123.set_counter!(rngs[trial], trial)
end

f(trial, rng) = ...
pmap(f, 1:numtrials, rngs)
```

Is using `set_counter!` this way the right approach to give independent RNGs?
Will it work for all RNGs in the Random123 family?
Why would I choose 2x or 4x version?
Which particular RNG would you recommend?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.