[R] random number generator

John Logsdon j.logsdon at lancaster.ac.uk
Thu Jan 20 10:58:42 CET 2000

```
On Thu, 20 Jan 2000, Prof Brian D Ripley wrote:

> On Wed, 19 Jan 2000, Clayton Brown wrote:
>
> > This question may not be specific to R, but I'm using R so here goes:
> >
> > Since R is slow (as is Splus) I want to split a simulation and run it on
> > 2 or 3 systems at once.  The simulations involve generating a large number
> > of random values.  How can I set .Random.seed so that the succession of
> > random values don't overlap across systems.
> >

[snip]

>
> Calculation: my machine can generate about 10^5 RNG per second. Suppose you
> do something with them, so you use 10^4 per second (optimistic!)  Then in
> 24 hours you will use less than 10^9. Super-Duper and Marsaglia-Multicarry
> have periods of over 10^18, so the chance of any overlap is less than
> 10^-9, and the chance of a damaging overlap are much less.
>

Of course this assumes that you haven't used the same RNG to 'randomise'
the seeds!  You need to initialise these on different machines manually!
Fortunately .Random.seed can be written to as:

.Random.seed<-c(0,1111,3333,5555)

But you can change the random number generator by .Random.seed[1] - see
?RNG for details so you could well initialise each machine using one
generator but use another generator for the main sequence.  Perhaps you
could initialise them from the clock as well - this is a standard
procedure.  proc.time() returns the time in seconds that have been used
but this is not very refined - is there a millisecond or finer resolution
anywhere that picks up a system clock rather than timing a procedure?

John

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```