[R] Random seed problem in MCMC coupling of chains

Kjetil Brinchmann Halvorsen kjetil at acelerate.com
Wed Jun 8 21:35:29 CEST 2005


Gorjanc Gregor wrote:

>Thanks to Paul and Gabor for additional tips/examples. Actually, I find
>Pauls suggestion with setRNG also nice and is exactly what I wanted. 
>Paul, if I understand this correctly, your suggestion with setRNG does not
>alter "RNG flow", it just takes care that chains really have equal seeds.
>I remember that I have read somewhere that destroying "RNG flow over and
>over to get real randomness" is not a good idea. Can someone confirm this?
>  
>
That's in Brian Ripley's Simulation book, and certainly in other places.

Kjetil

>niter <- 3
>nchain <- 2
>for (i in 1:niter) { # iterations
>  tmpSeed <- setRNG()
>  for (j in 1:nchain) { # chains
>    setRNG(tmpSeed)
>    a <- runif(1)
>    cat("iter:", i, "chain:", j, "runif:", a, "\n")
>  }
>}
>
>iter: 1 chain: 1 runif: 0.8160078
>iter: 1 chain: 2 runif: 0.8160078
>iter: 2 chain: 1 runif: 0.4909793
>iter: 2 chain: 2 runif: 0.4909793
>iter: 3 chain: 1 runif: 0.4425924
>iter: 3 chain: 2 runif: 0.4425924
>
>[... removed other stuff ...]
>
>Lep pozdrav / With regards,
>    Gregor Gorjanc
>
>----------------------------------------------------------------------
>University of Ljubljana
>Biotechnical Faculty        URI: http://www.bfro.uni-lj.si/MR/ggorjan
>Zootechnical Department     mail: gregor.gorjanc <at> bfro.uni-lj.si
>Groblje 3                   tel: +386 (0)1 72 17 861
>SI-1230 Domzale             fax: +386 (0)1 72 17 888
>Slovenia, Europe
>----------------------------------------------------------------------
>"One must learn by doing the thing; for though you think you know it,
> you have no certainty until you try." Sophocles ~ 450 B.C.
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
>
>  
>


-- 

Kjetil Halvorsen.

Peace is the most effective weapon of mass construction.
               --  Mahdi Elmandjra




-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.




More information about the R-help mailing list