J. Michael Oakes
> >
> > -set seed- is documented under -help generate-
> >
>
> Thanks, I've studied it and the associated citations. I'm
> not interested in
> wasting anyone's time. Instead I honestly don't see how the
> examples in the
> manuals or help files answer my question. The closest (help
> file) example I
> see is:
>
> . set seed 1829382
> . gen random = uniform()
> . sort random
> . local holdseed = c(seed)
> . gen unif10 = floor(uniform()*10) + 1
> . ... much later ...
> . set seed `holdseed'
> . gen same10 = floor(uniform()*10) + 1
>
> And this does not appear to generate a "random" or an
> "always different"
> seed. My read of the example is that it re-uses the seed
> saved in local
> macro `holdseed'. As far as I can tell, c(seed) yields the
> value of seed
> 1829382. Am I missing something here too?
>
> Regardless, I was simply hoping a Statalister could help me out.
Mostly people want the same seed, namely _reproducible_
results.
If you want _irreproducible_ results, then there is
more than one way to do it.
Suppose you are in a loop, running something each
time.
You could
local seed = <whatever>
forval i = 1/1000000000000000000 {
do myprog `seed'
local seed = `seed' + 1
}
so that each time round the loop
the seed is incremented. Within
myprog.do, the first line could pick up
the seed
local seed `1'
But strictly, that's reproducible.
So you could change the seed by adding
amounts themselves randomised:
local seed = <whatever>
forval i = 1/2 {
do myprog `seed'
local seed = `seed' + ceil(1000 * uniform())
}
etc.
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/