Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: sequence of random values is repeated as I re-run code


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: sequence of random values is repeated as I re-run code
Date   Fri, 4 Feb 2011 15:09:48 +0000

Next guess: If you start each session with a call to your program, you start with the same seed. 

I just left Stata, got in again and did this:

. di c(seed)
X075bcd151f123bb5159a55e50022865746ad

And then the same again: 

. di c(seed)
X075bcd151f123bb5159a55e50022865746ad

Looks the same to me. 

So, a test of your problem is open Stata, do your thing two, three, ... times in a session and tell us whether it is still true. 

Also, even if you don't -set seed- are you sure that nothing you are using does not do that? 

Nick 
n.j.cox@durham.ac.uk 

Prado De Castro Alfaiate, Jorge

Dear ergiy Radyakin and Nick Cox, 

Thank you for your answers. 

In my code I basically maximize a function several times using ml. I set different initial (random) values each time...

What I find "weird" is that everytime that I re-run the code Stata delivers the exact same initial values (that is, the same random numbers) as in the previous time I run it... Therefore this means that the same sequence of random numbers generated was repeated (and my code requires about thousands of random numbers)...

I don't set "seed" anywhere in my code and am thus solely relying on Stata to provide different random numbers each time. 

________________
De: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] em nome de Nick Cox [n.j.cox@durham.ac.uk]
Enviado: sexta-feira, 4 de Fevereiro de 2011 14:39
Para: 'statalist@hsphsun2.harvard.edu'
Assunto: RE: st: sequence of random values is repeated as I re-run code

Using the "true random numbers" is still basing your actions on a physical theory that the series really is, or should be, structureless noise, and they are not even pure from nature. In what I take to be Sergiy's own words:

"This service samples atmospheric noise via radio tuned to an unused
broadcasting frequency together with a skew correction algorithm due to John von Neumann."

It seems to be a choice between one set of assumptions that statistical people in practice take on trust assuming that some expert knows their field and another set of assumptions about which the same can be said.

Nick
n.j.cox@durham.ac.uk

Sergiy Radyakin

On Fri, Feb 4, 2011 at 7:07 AM, Prado De Castro Alfaiate, Jorge
<jprado@essex.ac.uk> wrote:
>
> I still could not understand why, but I found out that the same sequence of random values is created when I re-run my code.
>
> Each time a random value is created Stata is supposed to get that random number by using a complicated function of time and date (with high precision), leading to a near-random number, right?
>
> But then I do not understand how the same random numbers may come out again...
>

I guess you have discovered the fundamental truth about random number
generation in Stata (and all the other packages and programming
languages for that matter).The random number generation is implemented
with a pseudo-random number generator, which repeats the same sequence
over and over again, and that sequence appears to be random to the
naked eye, but it is of course not. For practical matters the
following properties are particularly notable: it has a repetition
cycle, and a sophisticated guesser equipped with a calculator, good
memory and a prior knowledge of the previous few observations of the
rnds can predict with 100% certainty what's coming next.

Being able to reproduce the same sequence of random numbers is often
important during software development for testing and making sure the
software behaves properly.

For true random numbers, see the -truernd- command recently posted to SSC.
http://ideas.repec.org/c/boc/bocode/s457232.html

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index