Properly Running Chains in Parallel

64 views
Skip to first unread message

Markian Pahuta

unread,
Oct 17, 2014, 12:09:53 PM10/17/14
to stan-...@googlegroups.com
Hi

I just want to make sure that I will be running 3 independent chains with the following code (I'm using Linux). Specifically, am I defining rng_seed OK?

library(parallel)
library
(rstan)

setwd
('~/ions/')

load
('Co_data_oct16.dat')

foo
<- stan(file = 'oct16.stan', data = datalist, chains=0)
rng_seed
<-12345
sflist
<- mclapply(
         
1:3,
          mc
.cores = 3,
           
function(i) stan(fit = foo,
                            data
= datalist,
                            iter
=5000,
                            thin
=5,
                            seed
= rng_seed,
                            chains
= 1,
                            chain_id
= i,
                            refresh
= -1))

modfit
<- sflist2stanfit(sflist)



thanks

Mark

Bob Carpenter

unread,
Oct 17, 2014, 12:14:44 PM10/17/14
to stan-...@googlegroups.com
Yes, the key is having different chain_id. This advances
the random number generator a very big step (more than you'd
have time to genrate), thus making the draws in the different chains
come from different slices of the pseudo-random number sequence
determined by the seed.

This works the same way in the other interfaces, too.

- Bob
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages