Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Random seeder


From   Antoine Terracol <Antoine.Terracol@univ-paris1.fr>
To   statalist@hsphsun2.harvard.edu
Subject   st: Random seeder
Date   Wed, 29 Sep 2010 14:35:50 +0200

Hi _all,

some time ago, there was a discussion on Statalist about getting a random seed for Stata's PRNG. Bill Gould suggested that someone should write a little program to obtain (true) random numbers from random.org (see http://www.stata.com/statalist/archive/2010-08/msg00930.html )

Based on R's random package, here's a first try, for anyone interrested

program define truernd, rclass
syntax [,min(integer 1) max(integer 1000000000) setseed]
tempfile rndseed
tempname myseed
tempname value
quietly copy "http://www.random.org/integers/?num=1&min=`min'&max=`max'&col=1&base=10&format=plain&rnd=new" `rndseed'.txt , replace
file open `myseed' using `rndseed'.txt, read text
file read `myseed' `value'
file close `myseed'
return scalar rndvalue=``value''
di "The value returned by www.random.org is ``value''"
if "`setseed'"!="" {
set seed ``value''
display "The seed was set to ``value''"
return scalar seed=``value''
}
end
truernd

--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index