random number generation issues with r and compiled C code
On Fri, 25 Jan 2002, Faheem Mitha wrote:
On Thu, 24 Jan 2002, Prof Brian Ripley wrote:
3) When using standalone Rmathlib A little care is needed to use the random-number routines. You will need to supply the uniform random number generator double unif_rand(void) or use the one supplied (and with a shared library or DLL you will have to use the one supplied, which is the Marsaglia-multicarry with an entry point set_seed(unsigned int, unsigned int) to set its seeds). So, I'm not clear if you have supplied your own or used the one supplied, but if the latter, you need to call set_seed, *but only once*.
Thank you for the reply. I used the one supplied (set_seed). So can I call set_seed from the top level of my C code; ie from main(), which then calls other functions which call unif_rand() etc?
Yes, you can do it. What it does is to set internal C variables which unif_rand() consults. It's all in .../src/nmath/standalone/sunif.c, and it is easier to read the code than to try explain it to you in words.
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._