0
$\begingroup$

This question arises from my attempt to mix two different RNGs. I'd like to mix them choosing the best of the two according to the operations I need to carry out to achieve better performance. I'm restricted to use a Mersenne Twister (MT19937) RNG with any other RNG listed here:

  • PCG-64
  • PCG-64 DXSM
  • MT19937
  • Philox
  • SFC64

Also, a requirement of my project is that I need to have reproducible results so unpredictable entropy should be avoided to set the seeds, but I can set one of the seed with a pseudorandom number generated with one of the RNG if needed.

I read here that using two Mersenne Twister can be problematic in terms of the quality/correlation of the sequence generated. So another MT19937 seems not a good choice at least if I don't pass the state of the first MT19937 to this new other when I need to carry out some operations, but this type of procedure creates a relevant overhead. Can any of the others be initialized together with a MT19937 without incurring in these problems? Or is there any other solution? I posted a similar question on StackOverflow where it is described also the specific programming context where an answer to this question can prove useful to me. Thank you in advance!

$\endgroup$
7
  • 4
    $\begingroup$ Define what "best" means to you. $\endgroup$ Feb 2, 2023 at 22:27
  • $\begingroup$ I'm not sure what you are referring to but I'd like to have a sequence of numbers so that there is no correlation achieving the best performance in mixing two generators, where one has to be a MT19937 $\endgroup$
    – Tortar
    Feb 2, 2023 at 22:33
  • 1
    $\begingroup$ Well, the thing is that for every non-random sequence, some kind of correlation can be found if you just look hard enough. And no RNG produces random sequences, though all modern RNG sequences are very good, including for that matter MT19937. $\endgroup$ Feb 3, 2023 at 3:04
  • 4
    $\begingroup$ But what I meant with "define best" is that you say "achieving the best performance in mixing two generators": How would you measure "best performance"? How will you know that one way of mixing generators is better or worse than another way of mixing generators? $\endgroup$ Feb 3, 2023 at 3:05
  • $\begingroup$ In my case it's clear I think since I have a rather specific problem in mind as you can read in the linked question on stack overflow: to choose between the default random rng and the Numpy rng, I manually calculated where one is better than the other timings the different functions as you can see in the other question $\endgroup$
    – Tortar
    Feb 4, 2023 at 21:38

1 Answer 1

1
$\begingroup$

Maybe I've found a solution myself, hope that someone knowledgable can check if this is correct!

I can use a second MT19937 with the same seed where I jump ahead the state of the generator at the start of the simulation with a step size which can be impossible to arrive at with the first generator so that it is like having only one generator throughout the all simulation.

It is possible to do so as described in

  • Hiroshi Haramoto, Makoto Matsumoto, Takuji Nishimura, François Panneton, Pierre L’Ecuyer, “Efficient Jump Ahead for F2-Linear Random Number Generators”, INFORMS JOURNAL ON COMPUTING, Vol. 20, No. 3, Summer 2008, pp. 385-390.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.