8
$\begingroup$

I have code that uses both RandomReal and RandomInteger a number of times to produces a sequence of $n$ data sets. After closing the notebook and quitting the kernel, I would like to be able to start the code where I left off in the random sequence, and generate an additional $m$ data sets.

I can do this with the old Random function and $RandomState. But, how do I do it with RandomReal and RandomInteger?

$\endgroup$
9
  • 6
    $\begingroup$ Probably with Random`GetRandomState and Random`SetRandomState. These are undocumented and might crash your kernel. I did get a crash with them yesterday. Related: mathematica.stackexchange.com/questions/91523/… $\endgroup$ – Szabolcs Aug 14 '15 at 12:20
  • 1
    $\begingroup$ But is it really important for your application where you are exactly in the random sequence? Can you explain a bit more? $\endgroup$ – Szabolcs Aug 14 '15 at 12:21
  • 3
    $\begingroup$ start with SeedRandom, keep count of the random calls. Restart with same seed and make the right number of random calls to get back to the same point, $\endgroup$ – george2079 Aug 14 '15 at 12:40
  • 2
    $\begingroup$ @george, but if one was doing Monte Carlo with a few million or so calls to the PRNG before you lost patience, you'd hope there was a convenient way to pick up where you left off without going through that first few million again, no? For a congruential generator, this is not too hard to do, but of course nobody uses purely congruential generators in a nontrivial Monte Carlo application… $\endgroup$ – J. M.'s ennui Aug 14 '15 at 12:50
  • $\begingroup$ @J.M. I see that "jumping ahead" by precisely $n$ steps is discussed for many different generators. What is the practical use of this? $\endgroup$ – Szabolcs Aug 14 '15 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.