From tyler.smith at mail.mcgill.ca  Thu Jul  3 15:13:20 2008
From: tyler.smith at mail.mcgill.ca (tyler)
Date: Thu, 03 Jul 2008 10:13:20 -0300
Subject: [Rd] GetRNGstate and PutRNGstate
Message-ID: <878wwjkt5b.fsf@blackbart.sedgenet>

Hi,

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
PutRNGstate().

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.

Thanks,

Tyler

--



[Rd] GetRNGstate and PutRNGstate
tyler