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: Setting same seed, getting different random numbers.


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Setting same seed, getting different random numbers.
Date   Thu, 1 Dec 2011 10:25:47 +0100

I think you need to set the seed inside mata:

*-------------- begin example ---------------
mata
rseed(2)
rnormal(1,1,0,1)

rnormal(1,1,0,1)

rseed(2)

rnormal(1,1,0,1)

end
*----------------------- end example -------------------

Hope this helps,
Maarten

On Wed, Nov 30, 2011 at 10:29 PM, Patrick Roland
<[email protected]> wrote:
> I encountered a strange problem. I tried running the same code on two
> different versions of Stata - one Stata/SE 12.0 on a server, and one
> Stata/SE 11.2 on my own computer. Both generate normal random numbers
> in mata with the same seed. But after a while the random numbers they
> generate differ! The code is as follows
>
> set seed 2
> mata
> f = rnormal(1000000,1,0,1)
>
> On the two machines, f[1,1] = .7005116833. But one one f[1000000,1] =
> -.5182349644, and on the other it is .7083750352.
>
> This strikes me as bizarre and impedes replication of my code across
> computers. Any ideas as to what's going on here?
>
> Thanks.
> *
> *   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/



-- 
--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------

*
*   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