[R] random numbers

Dirk Eddelbuettel edd at debian.org
Sat Jun 30 21:50:24 CEST 2007


On 30 June 2007 at 12:12, Ross Boylan wrote:
| I call C++ code from R to generate simulated data.  I'm doing this on a
| cluster, and use rmpi and rsprng.  While rsprng randomizes R-level
| random numbers (e.g., from runif), it has no effect on the C code, which
| is completely SPRNG and MPI ignorant.
| 
| Currently I generate a seed to pass into the C code, using
| as.integer(runif(1, max=.Machine$integer.max)-.Machine$integer.max/2)
| It seems to work.
| 
| Any comments on this approach?  Here are some issues I see:

I may be missing something but given that rsprng is running on your cluster,
you are bound to also have sprng itself -- so why don't you use that from C
or C++  for this purpose?

Hth, Dirk

-- 
Hell, there are no rules here - we're trying to accomplish something. 
                                                  -- Thomas A. Edison



More information about the R-help mailing list