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$ Commented Aug 14, 2015 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$ Commented Aug 14, 2015 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$ Commented Aug 14, 2015 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$ Commented Aug 14, 2015 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$ Commented Aug 14, 2015 at 13:28

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.