[Rd] GetRNGstate and PutRNGstate

tyler tyler.smith at mail.mcgill.ca
Thu Jul 3 15:13:20 CEST 2008


I've got a simulation function, written in C and called from R, that
uses the R random number functions. It's not a very complicated
simulation - 280 lines total, with the main function (the one called
with .C) repeatedly calling another function, with multiple calls to
unif_rand() in both functions. At the beginning of the main function I
call GetRNGstate(), and the last thing I do before returning to R is

On rereading Chapter 5 of the R Extensions manual, I'm not sure I
understand the GetRNGstate/PutRNGstate calls. Should I also include them
in the helper function? Do I need to wrap every call to unif_rand with
these calls, or is it ok that I've just used them at the beginning and
end of the C code? 

I'm getting different results from different simulations, so what I've
done appears ok, but I'm not sure I would be able to detect if every
call to the helper function was returning the same result.




More information about the R-devel mailing list