Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Query on -set seed-

From   "David Harrison" <>
To   <>
Subject   st: RE: Query on -set seed-
Date   Tue, 8 Feb 2005 09:17:30 -0000

I can't say if anything has changed since last summer as my executable is still on the 23 Jul 2004 version (trying to find a convenient time for everyone on the network license to update...), but I can tell how Stata (in this executable at least) deals with "illegally high" seeds...

The first argument of the KISS generator is updated mod 2^32 - so if you give -set seed- an argument greater than or equal to 2^32, this is just treated mod 2^32. In your case:

. set seed 4753533809

. di c(seed)

. set seed `=4753533809-2^32'

. di c(seed)

This still leaves a bit of a hole from 2^31 to 2^32-1. Any argument # in this range is treated as 2^32-#, for example:

. set seed 3000000000

. di c(seed)

. set seed `=2^32-3000000000'

. di c(seed)

None of this explains why the output of your do-file has changed. Have you tried rerunning the do-file twice? Does it give the same results both times? Have you tried running it twice with a lower ("legal") seed? Some procedures just do not seem to be reproducible...

Hope this helps


-----Original Message-----
From: Roger Newson []
Sent: 07 February 2005 21:49
Subject: st: Query on -set seed-

Fellow Statalisters (especially StataCorp):

According to -[R] functions-, the -set seed- command can take any seed from 
0 to 2^31-1 inclusive, and, if I specify a seed with one of these values in 
a do-file under -version- control and then use the -uniform()- function, 
then the same result will be produced every time I execute that do-file 
with the same input data. My query is, will this still be the case if I set 
the seed to an even higher integer? I ask because, last July, I 
inadvertently wrote a do-file containing the statements

set seed 4753533809;
gene double ranord2=uniform();

and executed it on 15 July 2004 under Stata 8.2 under Windows 2000, 
producing some random-looking results and no complaints about the illegally 
high seed. However, when I re-executed the same do-file today (7 September 
2005) with the same input dataset under the Stata 8.2 update dated 10 
January 2005, it produced a completely different set of random-looking 
results, and still no complaints about the same illegally high seed. Have 
there been any unpublicised revisions to -set seed- or to -uniform()- 
affecting the response to an illegally high seed?

Best wishes (and thanks in advance)


*   For searches and help try:

© Copyright 1996–2023 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index