Hi All,

I am trying to outsource the simulation of binomially distributed random 
variables to C++ via Rcpp (e.g. to replicate the R command 
rbinom(10,10,c(1:10)/20)). This works well as long as the third argument of the 
function (i.e. the probability) is a single value and not a vector. I tried to 
compile the following code:

rbinom_c =rcpp( signature(n = "integer",m = "integer",p="numeric") , body="int 
N = as<int>(n); int M = as<int>(m); NumericVector P = NumericVector(p); 
NumericVector res = rbinom(N,M,P); return res; ")

But the compiler expects a “double” variable in the third argument. Is there a 
way of fixing the code without using an explicit loop in the C++ code?


Thanks 

Carsten
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to