# Restarting random number generators where you left off

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? • Probably with RandomGetRandomState and RandomSetRandomState. These are undocumented and might crash your kernel. I did get a crash with them yesterday. Related: mathematica.stackexchange.com/questions/91523/… – Szabolcs Aug 14 '15 at 12:20 • But is it really important for your application where you are exactly in the random sequence? Can you explain a bit more? – Szabolcs Aug 14 '15 at 12:21 • 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, – george2079 Aug 14 '15 at 12:40 • @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… – J. M.'s ennui Aug 14 '15 at 12:50 • @J.M. I see that "jumping ahead" by precisely$n\$ steps is discussed for many different generators. What is the practical use of this? – Szabolcs Aug 14 '15 at 13:28