Generating same random variable in Rcpp and R
问题 I am converting my sampling algorithm from R to Rcpp. Output of Rcpp and R are not matching there is some bug in the Rcpp code ( and the difference is not different because of randomization). I am trying to match internal variables of Rcpp with those from R code. However, this is problematic because of randomization due to sampler from distribution. Rcpp::rbinom(1, 1, 10) rbinom(1, 1, 10) How can I make the code give same output in R and Rcpp, I mean setting a common seed from R and Rcpp? 回答1