It seems that, the sample
functions from RcppArmadillo
and R
return the same outputs when I set fixed the seed for each sample. However, I get different outcomes in my case.
Here is my code
// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
#include <RcppArmadilloExtensions/sample.h>
using namespace Rcpp;
using namespace arma;
using namespace std;
// [[Rcpp::export]]
NumericVector f(int N, NumericVector x)
{return Rcpp::RcppArmadillo::sample(x, N, false);}
/*** R
set.seed(123)
f(5, 1:5)
[1] 2 4 5 3 1
set.seed(123)
sample(1:5, 5, FALSE)
[1] 3 2 5 4 1
*/
Does someone know why?