开发者

Random number generation with doSMP

开发者 https://www.devze.com 2023-03-04 12:18 出处:网络
I\'m trying to use doSMP package for parallel programming i开发者_StackOverflow中文版n R. Here\'s a snippet of the code I wrote to test whether each MC replicate starts from the same seed, and whether

I'm trying to use doSMP package for parallel programming i开发者_StackOverflow中文版n R. Here's a snippet of the code I wrote to test whether each MC replicate starts from the same seed, and whether RNG will give the same number The random numbers come out the same. I want each MC replicate to be random(I generate random numbers in run.MC.replicate). How can I fix this?

par.mc.result<- foreach(mc =1:nmc,.packages=c("MASS") ) %dopar% {

    source("./src/simulation_math_util_fn.R")

    source("./src/oosMDS.R")
    source("./src/smacofM.R")
    source("./src/oosIM.R")
    sink(file=paste("debug",mc,collapse=""))
    print(runif(1))
            run.MC.replicate(myParams)

    }

I'm guessing this behaviour happens because of the way doSMP generates child R processes. Please help


You need a RNG suited for parallel computing. Go to the High Performance Computing Task View and see the Parallel computing: Random numbers section. It lists the rsprng and rlecuyer packages.

0

精彩评论

暂无评论...
验证码 换一张
取 消