Hi, I need an advice. I'm writing a Markov Chain Monte Carlo subroutine in F95 which should be called from R. I noticed that the subroutine RANDOM_NUMBER takes the seed from R (is that correct?). I was wondering if is better initialize the random seed inside the F95 subroutine or use the R seed. Regards, Filippo
On 04/08/2013 21:38, Filippo wrote:> Hi, > I need an advice. > I'm writing a Markov Chain Monte Carlo subroutine in F95 which should be > called from R. I noticed that the subroutine RANDOM_NUMBER takes the > seed from R (is that correct?).It is not correct.> I was wondering if is better initialize the random seed inside the F95 > subroutine or use the R seed.Use R.> Regards, > Filippo > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.Please do: the answer is in the R manuals, and this was an R-devel question (see what the posting guide says about non-R programming questions). -- 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Hi Filippo, I would advice you to use the RcppArmadillo package - maybe in combination with the inline package. It is extremely fast and very flexible. A simple RNGScope() lets you take the RNG from R. I myself programmed an MCMC sampler with this package and it is much faster, than the one I had before in matlab. Rcpp gives you a very nice API to communicate with R + you can reuse memory from R which makes it even faster. You find a lot of documentation online: http://www.rcpp.org http://cran.r-project.org/web/packages/RcppArmadillo/index.html http://cran.r-project.org/web/packages/Rcpp/index.html Best Simon On Aug 4, 2013, at 10:38 PM, Filippo <ingfimo at gmail.com> wrote:> Hi, > I need an advice. > I'm writing a Markov Chain Monte Carlo subroutine in F95 which should be called from R. I noticed that the subroutine RANDOM_NUMBER takes the seed from R (is that correct?). > I was wondering if is better initialize the random seed inside the F95 subroutine or use the R seed. > Regards, > Filippo > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.