[R] random seed puzzle

Liaw, Andy andy_liaw at merck.com
Tue Aug 3 14:10:02 CEST 2004


My guess is that
http://cran.r-project.org/src/contrib/Descriptions/rlecuyer.html might be
relevant, too.

Cheers,
Andy

> From: Duncan Murdoch
> 
> On Mon, 2 Aug 2004 17:50:44 -0500, "Bickel, David"
> <DAVID.BICKEL at PIONEER.COM> wrote:
> 
> >After reading the help page on set.seed, I am unsure about 
> how to solve the following problem. I need to call function f 
> a thousand times. The list of values returned by f, should be 
> as random as possible. f calls g twice:
> >	f <- function(){g1 <- g(1); g2 <- g(2); c(g1; g2)}
> >The function g in turn calls sample and returns a number, 
> but also depends on its argument, so, starting from the same 
> seed, g(1) returns a different number than g(2). I need each 
> call to g to start with the same random number seed, so that 
> the values returned by f would not be affected by redefining 
> it this way:
> >	f <- function(){g2 <- g(2); g1 <- g(1); c(g1; g2)}
> 
> This is a problem that's like what people doing simulations on
> parallel computers worry about.  You might want to look at the sprng
> package.  (I haven't used it, so I'm not sure it does what you need). 
> 
> Duncan Murdoch
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list