Dear All,

I have three classes of questions about generating random numbers with
different packages (windows xp 32bit R).
.
1. Suppose I would like to use package *foreach*, can I use current
Sys.time as a seed?
Although I can get the time up to1e-6 second precesion, the code below dose
not work well on a local machine with two cores. #################
library(foreach)
library(snow)
library(doSNOW)
testfun=function(){
             options(digits.secs=6)
             set.seed(slave.seed <- substring(Sys.time(), 21, 26))
             a <- rnorm(5,0,1)
             return(a)
                               }
maxkk <- 5
cl <- makeCluster(5, type = "SOCK")
registerDoSNOW(cl)
results=foreach (i = 1:maxkk, .combine = 'rbind') %dopar% testfun()
results
stopCluster(cl)
#################

2. Suppose I want to use *snow*, according to some reference, I need to use
*rsprng* as a generator. Does this generator relay on seed as well? But it
seems to me that if I do not use rsprng, it is also fine.
## code without rsprng ##
testfun <- function(){
   a <- rnorm(5,0,1)
   return(a)
       }
library(snow)
cl <- makeCluster(5,type="SOCK")
clusterCall(cl, testfun)
stopCluster(cl)

## code with rsprng ##
testfun <- function(){
   a <- rnorm(5,0,1)
   return(a)
       }
library(snow)
library(rsprng)
cl <- makeCluster(5,type="SOCK")
clusterSetupRNG(cl)
clusterCall(cl, testfun)
stopCluster(cl)

3. Suppose I would like to use the package *parallel, *do I still need *
rsprng? *Should I specify any seed in this case?

testfun <- function(){
   a <- rnorm(5,0,1)
   return(a)
       }
library(parallel)
cl <- makeCluster(5,type="SOCK")
clusterCall(cl, testfun)
stopCluster(cl)

My questions can also be viewed as these aspects: how do these generators
work with/without seed, what is the relation between these packages, what
is the best option of seed if needed.
Thank you very much for your help.

Best wishes,
Jie

	[[alternative HTML version deleted]]

