Displaying 2 results from an estimated 2 matches for "tmpseed".
2005 Jun 08
6
Random seed problem in MCMC coupling of chains
Hello!
I am performing coupling of chains in MCMC and I need the same value
of seed for two chains. I will show demo of what I want:
R code, which might show my example is:
niter <- 3
nchain <- 2
tmpSeed <- 123
for (i in 1:niter) { # iterations
for (j in 1:nchain) { # chains
set.seed(tmpSeed)
a <- runif(1)
cat("iter:", i, "chain:", j, "runif:", a, "\n")
tmpSeed <- .Random.seed
}
}
I get this:
iter: 1 chain: 1 runif: 0.43588
iter...
2005 Jun 08
1
FW: Random seed problem in MCMC coupling of chains
...ber of
random numbers in each pass through the chain. If that is not the case
then even with the setRNG utilities there is a subtle change that you
are introducing.
HTH,
Paul
>
> niter <- 3
> nchain <- 2
startingRNG <- setRNG()
> 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.816007...