If there is a seed set in R before rngs() is called, then "RNGScope z;" can be omitted, right?<br><br>I used to use RNGScope() to set seed. I guess that is not the right way, is it?<br><br>My test shows, with RNGScope(), even if I re-compile (without quitting R), rngs always gives the same numbers. I have to quit R and then re-compile to get random numbers. There is no such problem with "RNGScope z".<br>
<br>Zhongyi<br><br><div class="gmail_quote">On Thu, Sep 1, 2011 at 12:15 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
I should have written that quick function as follows:<br>
<div class="im"><br>
rngs <- cxxfunction(signature(), plugin="Rcpp",<br>
</div> body="RNGScope z; return Rcpp::rnorm(5,0,1);")<br>
<br>
You _do_ want RNGScope around; my bad for omitting it in the previous post.<br>
<font color="#888888"><br>
Dirk<br>
</font><div><div></div><div class="h5"><br>
--<br>
Two new Rcpp master classes for R and C++ integration scheduled for<br>
New York (Sep 24) and San Francisco (Oct 8), more details are at<br>
<a href="http://dirk.eddelbuettel.com/blog/2011/08/04#rcpp_classes_2011-09_and_2011-10" target="_blank">http://dirk.eddelbuettel.com/blog/2011/08/04#rcpp_classes_2011-09_and_2011-10</a><br>
<a href="http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php" target="_blank">http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php</a><br>
</div></div></blockquote></div><br>