What does the integer while setting the seed mean?

Prateek Kulkarni picture Prateek Kulkarni · Feb 4, 2013 · Viewed 18.6k times · Source

I want to randomly select n rows from my data set using the sample() function in R. I was getting different outputs each time and hence used set.seed() function to get the same output. I know that each integer in the set.seed() will give me a unique output and the output will be the same if set the same seed. But I'm not able to make out what that integer that is passed as a parameter to the set.seed() function means. Is it just an index that goes into the random generator algorithm or does it mean some part of the data from where you start sampling? For example, what does the 2 in set.seed(2) mean?

Answer

Charlie picture Charlie · Feb 4, 2013

In the old days, there were books that contained pages and pages of random digits (in a random order, of course).

I like to think of set.seed(x) as telling the computer to start reading random numbers from page x in a huge book of random numbers. x has nothing to do with the data, but how the algorithm for choosing random numbers should begin.

This might be a bit facile, but I like the analogy.