<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I found a solution via Rcpp::Function and then using the R function set.seed. But I do not know what happens, when iterations run in parallel....I fear, that then this solution shows undefined behavior.<div> <br><div><div>On Feb 10, 2013, at 10:33 AM, Simon Zehnder <<a href="mailto:szehnder@uni-bonn.de">szehnder@uni-bonn.de</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Actually I arrived at another fundamental question: <div><br></div><div>I read '6.3 Random Number Generation' in the R Extensions Guide. It seems that it is not possible to set out of C++ the random seed (the wrapper RNGScope calls GetRNGstate() and PutRNGState() so it should have no extended functionality), which is very important when trying to produce reproducible results. So, I need a Mersenne-Twister, but I must be able to set the seed in every iteration. I think this brings me to the GSL library or - as long only normal random variates are needed - to the C++ std::random header?</div><div><br></div><div><br></div><div>Best Simon</div><div><br></div><div><br><div><div>On Feb 9, 2013, at 5:42 PM, Yan Zhou <<a href="mailto:zhouyan@me.com">zhouyan@me.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><blockquote type="cite"><div class="msg-quote"><div class="_stretch"><br> This really is a BIG topic and worth a few more comments. Note that I wrote a<br> few related posts on RNGs at the Rcpp Gallery, see for example<br> <br> <a href="http://gallery.rcpp.org/articles/timing-normal-rngs/" data-mce-href="http://gallery.rcpp.org/articles/timing-normal-rngs/">http://gallery.rcpp.org/articles/timing-normal-rngs/</a><br> <br> which compares the RNGs from R, C++11 and Boost. Simon just added Armadillo to<br> the list, we can add even more RNGs fromn other packages.</div></div></blockquote><span> </span></div><div>If it is of interest to anyone, I once timed Boost, C++11 and Random123 (A high performance parallel RNG, <a href="http://www.thesalmons.org/john/random123/releases/latest/docs/">http://www.thesalmons.org/john/random123/releases/latest/docs/</a>, It come with a C++11 compatible RNG engine, can be used just like std::mt19937) once for different compilers on Linux. I just uploaded them to <a href="https://github.com/zhouyan/vSMC/wiki/RNG-performance-comparison">https://github.com/zhouyan/vSMC/wiki/RNG-performance-comparison</a></div><div><br></div><div>There are two benchmark, one for the performance of URNG (mt19937 etc). These include those in C++11 <random> and Boost.Random, which are almost identical in functionality (C++11 <random> is based on Boost.Random after all). Also they include two URNG from Random123, threefry and philox (both come with four basic configurations)</div><div><br></div><div>Another benchmark is the performance of generating distribution random numbers (such as normal). The Random123 threefry2x64 was used for all distribution and compilers, since it is the one with least performance difference between compilers.</div><div><br></div><div>Compilers include,</div><div>clang SVN with libstdc++ 4.7</div><div>clang SVN with libc++ SVN</div><div>gcc 4.7</div><div>intel icpc 13</div><div><br></div><div>clang and gcc version also come with results when using AMD libm instead of glibc. However, the benchmark are not Rcpp specific. They are compiled to standalone C++ programs. But all these URNGs can be used Rcpp. As demonstrated in Dirk's example. </div><div><br></div><div>Best,</div><div><br></div><div>Yan Zhou</div><div><br></div></blockquote></div><br></div></div>_______________________________________________<br>Rcpp-devel mailing list<br><a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</blockquote></div><br></div></body></html>