2

How can we extract seed number in generating some random number. For example in the following example we generate 100 random standard normal with seed number=1234.

set.seed(1234)
x<-rnorm(100,mean=0,sd=1)

Now we want to know, how can we find out seed number when we generate these random number:

x<-rnorm(100,mean=0,sd=1)
Magicmahdi
  • 83
  • 2
  • 12
  • 2
    it's not really feasible to go backward in this way. You might want to search SO for `set.seed` and `Random.seed`, e.g. http://stackoverflow.com/questions/19614314/can-i-get-seed-somehow – Ben Bolker Nov 19 '13 at 14:25
  • thanks, so there is no straightforward way to find out the seed number and that link you shared is a substitute for the problem. Thanks – Magicmahdi Nov 19 '13 at 15:25
  • Note that: There is no guarantee that different values of seed will seed the RNG differently, although any exceptions would be extremely rare. – James Nov 19 '13 at 15:36
  • 1
    Obvious question: why? Just add `set.seed` before running your code. If you didn't do so, and also failed to save the vector `x` you generated, well shame on you :-). (because if you have `x` you can pseudoreproduce the sequence by `y<-x[1:N]` – Carl Witthoft Nov 19 '13 at 18:27

0 Answers0