help for setrngseed                                

Set random-number seed using random integer from random.org

setrngseed [, options]

options description ------------------------------------------------------------ none set seed

verify set seed, but first verify random.org working

query do not set seed; report random.org quota nosetseed do not set seed, report it instead ------------------------------------------------------------


Typing setrngseed without arguments is an alternative to using Stata's set seed command. setrngseed obtains truely random integers from www.random.org and uses those results to set the seed of Stata's pseudo-random-number generator.

www.random.org will currently deliver roughly 32,000 seeds per 24-hour period. You can visit www.random.org and purchase additional random numbers should you need them, which is unlikely, or to make a donation in support of their efforts.

setrngseed is usually used without any options being specified.


verify specifies that before setting the seed, setrngseed verify that www.random.org is working as setrngseed expects. This involves obtaining two rather than one random number and so consumes your 24-hour quota more quickly.

www.random.org is a separate organization from www.stata.com, and thus they could change the way their site operates. When option verify is specified, setrngseed requests two random numbers and verifies that they are different from each other.

query does not set the random-number seed. It instead reports the number of seeds www.random.org would supply remaining in your 24-hour quota.

nosetseed does not set the random-number seed. It instead reports the seed that would have been set. nosetseed is used in debugging setrngseed.


setrngseed sets the Stata's random-number seed randomly based on measurements of atmospheric noise obtained from the website www.random.org.

As of September 30, 2010, www.random.org has a quota system in which each IP address starts off with a quota of 1,000,000 random bits which is topped off with up to 200,000 bits each 24-hour period. setrngseed uses 31 bits each time it sets Stata's random-number seed, so your quota starts off with approximately 32,258 seeds and is topped off with up to 6,451 seeds per day. Additional random bits can be purchased through the website.

setrngseed will very likely break if www.random.org changes the protocol for obtaining random numbers. If setrngseed fails repeatedly, please send the the authors email, but only after checking your current random-bit allowance with setrngseed, query.

Methods and formulas

A random integer between -1,000,000,000 and +1,000,000,000 is obtained from random.org, 1,000,000,000 is added to it, and that number is used to set the random-number seed.

Saved results

setrngseed saves the following in r():

Scalars r(seed) value returned by the web service (only if query has not been specified) r(quota) your current IP's quota (only if query has been specified)


Antoine Terracol, Université Paris 1 terracol@univ-paris1.fr

William Gould, StataCorp wgould@stata.com

Also see

Manual: [R] set seed, [D] generate

Online: help for set seed, random numbers