Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Background

I am trying to do a reproducible scientific analysis. My conclusions are not dependent on the random number generator, but the RNG does change the results ~1% between runs. I would like to define starting points for the RNG algorithm to reproduce the same result each time.

I am using the "Mersenne-Twister" algorithm only because it is the default in R.

I am using the RNG to sample parameter values from their distributions and I need about $10^7$ values for the complete analysis.

Question

Are there any consequences of the choice of a starting value? Intuitively, R's set.seed(0) feels very non-random, but rationally, I can't imagine why this would matter.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Depending on the algorithm the seed can indeed affect the quality of your random numbers however due to the design of mersenne twister the choice of the seed shouldn't really affect the length of the periodicity of the random numbers or their quality. Still there might be some implementations of the mersenne twister where the seed does matter as you can read here ( http://library.gnome.org/devel/glib/unstable/glib-Random-Numbers.html ) Obviously they changed the seeding algorithm because the first one could result in bad seeds. If you want to be on the safe side use a reliable library for your random numbers.

You might want to try something like this for getting the seed: http://www.stanford.edu/~blp/writings/clc/random-seed.html

Note that if you don't need too many numbers you could download real random numbers generated from atmospheric noise here: http://www.random.org/

share|improve this answer
    
With real random numbers, I don't think his computations will be reproducibly the same every single time. –  Willie Wong Jan 14 '11 at 20:25
    
Actually he could include the dataset he used into his project so it is reproducable. –  Listing Jan 14 '11 at 20:27
    
@user3123: technically true, but in that case wouldn't getting any pseudorandom string of 10^7 numbers do just as well? :) –  Willie Wong Jan 14 '11 at 20:54
    
Indeed, he should just use a reliable opensource library like boost::random that has been intensively tested and reference his seed. Actually 0 is ok too. –  Listing Jan 14 '11 at 20:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.