views:

73

answers:

2

Hi,

This is not a coding question, but am hoping that someone has come across this in the forums here. I am using Python to run some simulations. I need to run many replications using different random number seeds. I have two questions:

  1. Are negative numbers okay as seeds?
  2. Should I keep some distance in the seeds?

Currently I am using random.org to create 50 numbers between -100000 and +100000, which I use as seeds. Is this okay?

Thanks.

+3  A: 

Quoting random.seed([x]):

Optional argument x can be any hashable object.

Both positive and negative numbers are hashable, and many other objects besides.

>>> hash(42)
42
>>> hash(-42)
-42
>>> hash("hello")
-1267296259
>>> hash(("hello", "world"))
759311865
Matt Joiner
+3  A: 

Is it important that your simulations are repeatable? The canonical way to seed a RNG is by using the current system time, and indeed this is random's default behaviour:

random.seed([x])

Initialize the basic random number generator. Optional argument x can be any hashable object. If x is omitted or None, current system time is used; current system time is also used to initialize the generator when the module is first imported.

I would only deviate from this behaviour if repeatability is important. If it is important, then your random.org seeds are a reasonable solution.

Should I keep some distance in the seeds?

No. For a good quality RNG, the choice of seed will not affect the quality of the output. A set of seeds [1,2,3,4,5,6,7,8,9,10] should result in the same quality of randomness as any random selection of 10 ints. But even if a selection of random uniformly-distributed seeds were desirable, maintaining some distance would break that distribution.

Philip Potter
Thanks for the answer. Yes, it is very important that the simulations be repeatable.Let me ask a follow up question. Can one interpret from your answer that whether I choose 50 seeds drawn using the utility at random.org or whether I choose [1,2,...,50] as seeds, the quality of randomness would be the same. Thanks a ton.
Curious2learn
@Curious For a good quality RNG, the quality should not be dependent on the seed. The purpose of the seed is only to enable one algorith to generate many different streams of random numbers. Different seeds give different streams.
Philip Potter
@Philip - Thanks! Would you say the standard RNG in python (one obtained using the function random.uniform(a,b) a good RNG?
Curious2learn
@Curious It implements the [Mersenne Twister](http://en.wikipedia.org/wiki/Mersenne_twister), a very high quality RNG. But your question (and my answer) lack sufficient rigour: you need certain statistical properties from your distribution, and you want to ensure the distribution of the RNG satisfies those properies. In the end, I can tell you MT is "very good", but I can't say it's "good enough".
Philip Potter