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, **statalist.org** is already up and running.

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

From |
"Lachenbruch, Peter" <Peter.Lachenbruch@oregonstate.edu> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: Random start to random number sequence |

Date |
Thu, 19 Aug 2010 08:29:42 -0700 |

In using Bill's routine that gets the date and time, I found that it added 000 to the end and gave me numbers >2^31-1 which Stata didn't like. I made a simple change to get /* set seed for simulations */ local seed = tc(`c(current_date)' `c(current_time)')/1000 set seed `seed' display "seed is " c(seed) and all was well. Perhaps I goofed in the local command (without the /1000) Tony Peter A. Lachenbruch Department of Public Health Oregon State University Corvallis, OR 97330 Phone: 541-737-3832 FAX: 541-737-4001 -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of William Gould, StataCorp LP Sent: Thursday, August 19, 2010 8:10 AM To: statalist@hsphsun2.harvard.edu Subject: Re: st: RE: Random start to random number sequence Clyde Schechter <clyde.schechter@einstein.yu.edu> writes, > My approach to setting seeds [...] I take out my wallet and > examine the first currency note in it. I strip off any letters > from the serial number, and use that as the seed. I put the note > at the back of my wallet so I won't reuse that serial number. Ooh, I like it. I like it so much I'm going to use it. For those without currency in their wallets, there are web sites that will give you real random numbers. Real Random numbers ------------------- One site is http://www.random.org, which bases its numbers on atmospheric noise. Also see http://en.wikipedia.org/wiki/Random.org for more information on the site. Another is http://www.randomnumbers.info. They claim to to generate true random numbers using a quantum random-number generator. I just found both the above sites, but I should have known about them. My old favorite is http://www.lavarnd.org back in the days when the numbers were based on observations of a real lava lamp. Nowadays, Wikipedia informs me, lavarnd.org numbers are based on noise from the CCD of a cheap webcam, which doesn't have nearly the charm. The numbers are produced more quickly, however. Anyway, http://en.wikipedia.org/wiki/LavaRnd provides some history. To get a seed from lavarnd.org, go to the site and click on Lava Demos. You'll have a seed. I'm sure others can find more sites, and I suspect that most Statalist members would prefer that we don't report all the sites we find. If someone finds a site that is special, such as one that still uses a real lava lamp, or one that is particularly quick and easy to use, I suspect the other list members would tolerate it. I'd like to hear about it. For those interested in programming and performing a public service, see the P.S. at the bottom. You don't need real random numbers ---------------------------------- Using real random-number generators for statistical simulations would be overkill. Even using real random-number generators for setting the seed of Stata's generator is overkill, but unassailable. These sites exist for cryptological reasons. These people want real random numbers not just because such numbers are appearently random, but because they are truly unpredictable and thus cannot be reversed engineered. In our case, we don't care whether it would be possible for a sophisticated person to take a sample of our simulation and "break into" the rest of it. Indeed, we desire the opposite. We want our work to be easily reproducible by us and by others. Hence, Stata will display the state of the random-number generator if you code -display "`c(seed)'"-, and allow you to reset the generator back to that state later if you type -set seed ...-, substituting what was displayed. -- Bill wgould@stata.com P.S. A new command for Stata that reached out to the web and obtained a real random number, set Stata's random number seed, displayed the state of the random-number generator, and returned the state in r() to boot, would be neat. I'm imagining . setseed (contacting http://www....) (setting seed to 429839488) (RNG state is now X52359df4c43f462544a474abacbdd93d2fba) . return list macros: r(seed) : "X52359df4c43f462544a474abacbdd93d2fba" Programmers: If such a site existed, the trick to getting the random number would be tempfile fromweb copy "http://wwww..."; "`fromweb'" One could then process file "`fromweb'", possibly in Mata. To understand this method, try typing . copy http://www.stata.com trythis.html That will create file trythis.html. Take a look. If someone finds a site and undertakes this, please do not submit to SSC until someone else reviews your code. This command would reach out to a foreign website. Someone needs to verify that the site is on the up and up. And somone needs to review your code to verify that your code will do nothing bad if the website changes the format of what it produces. I volunteer. In fact, the review is probably unnecessary even if the site is evil and your code is poor. That's because Stata is not a web browser. Pretend www.evil.org is an evil web site that will do real damage to your computer if you just visited it in your web browser. Even so, in Stata, typing . copy http://www.evil.org badfile could not posibly do any damage to your computer because Stata does not interpret or even look at the contents being copied to the diskfile. The danger would be that you might later open badfile in your browser and that could do real damage. Reading badfile from Mata, however, would be safe because again, the evil code that is there is not interpreted. In any case, I recommend copying to a tempfile. That way, no one would even have time to open the file in a browser. And anyway, we will check out that the site is a safe one. <end> * * 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/ * * 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/

**References**:**Re: st: RE: Random start to random number sequence***From:*wgould@stata.com (William Gould, StataCorp LP)

- Prev by Date:
**Re: st: Current Population Survey and Stata, 2003-2005** - Next by Date:
**Re: st: Are my -xtmixed- intercepts accurate?** - Previous by thread:
**Re: st: RE: Random start to random number sequence** - Next by thread:
**Re: st: RE: Random start to random number sequence** - Index(es):