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

Re: st: RE: "random" seed for uniform()


From   David Kantor <[email protected]>
To   [email protected]
Subject   Re: st: RE: "random" seed for uniform()
Date   Thu, 09 Oct 2003 13:42:28 -0400

Michael Oakes wanted to know how to set the random seed to a "random" number -- if I interpret his request correctly.

Here is an old code fragment I have used. It gets its basis in the current time. The code may be a bit antiquated in its use of $S_TIME (I think there is now another way to get the time), but it should work. Also, this generates a 6-digit number; the newer random seed is allowed to be a much bigger number. So you can modify this if you see fit.

local time1 "$S_TIME"
local time2= substr("`time1'", 1,2) + substr("`time1'", 4,2) + substr("`time1'", 7,2)
disp "Setting seed to `time2'"
set seed `time2'

I hope this is useful.
-- David

David Kantor

Institute for Policy Studies
Johns Hopkins University
[email protected]
410-516-5404

*
* 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/




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