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 on April 23, and its replacement, is already up and running.

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

st: Random seeder

From   Antoine Terracol <>
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 (see )

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 "`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 is ``value''"
if "`setseed'"!="" {
set seed ``value''
display "The seed was set to ``value''"
return scalar seed=``value''

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:

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