rcpp

Bandits with Rcpp

南楼画角 提交于 2020-01-06 07:09:40
问题 This is a second attempt at correcting my earlier version that lives here. I am translating the epsilon-greedy algorithm for multiarmed bandits. A summary of the code is as follows. Basically, we have a set of arms, each of which pays out a reward with a pre-defined probability and our job is to show that by drawing at random from the arms while drawing the arm with the best reward intermittently eventually allows us to converge on to the best arm. The original algorithm can be found here.

Multi-armed bandits with Rcpp

泪湿孤枕 提交于 2020-01-06 07:07:38
问题 I am translating the epsilon-greedy algorithm for multiarmed bandits from here. This is a rather nice demonstration of the power and elegance of Rcpp. However, the results from this version do not tally with the one that is mentioned in the link above. I am aware that this is probably a very niche question but have no other venue to post this on! A summary of the code is as follows. Basically, we have a set of arms, each of which pays out a reward with a pre-defined probability and our job is

Multi-armed bandits with Rcpp

馋奶兔 提交于 2020-01-06 07:06:46
问题 I am translating the epsilon-greedy algorithm for multiarmed bandits from here. This is a rather nice demonstration of the power and elegance of Rcpp. However, the results from this version do not tally with the one that is mentioned in the link above. I am aware that this is probably a very niche question but have no other venue to post this on! A summary of the code is as follows. Basically, we have a set of arms, each of which pays out a reward with a pre-defined probability and our job is

How to write Rcpp function for simple matrix multiplication in R

拟墨画扇 提交于 2020-01-05 10:19:49
问题 I have wrote a Rcpp code to compute element wise matrix multiplication in R. But when try to run this code R stops working and its exiting. How to correct this function? Thanks in advance. library(Rcpp) func <- 'NumericMatrix mmult( NumericMatrix m , NumericMatrix v, bool byrow=true ) { if( ! m.nrow() == v.nrow() ) stop("Non-conformable arrays") ; if( ! m.ncol() == v.ncol() ) stop("Non-conformable arrays") ; NumericMatrix out(m) ; for (int i = 1; i <= m.nrow(); i++) { for (int j = 1; j <= m

Error from cppFunction(Rcpp) under R 15.2 Windows XP [duplicate]

£可爱£侵袭症+ 提交于 2020-01-05 08:22:31
问题 This question already has answers here : How to get Rcpp to work in R on a Windows XP platform? (3 answers) Closed 6 years ago . When I've called : cppFunction(' int add(int x, int y, int z) { int sum = x + y + z; return sum; }' ) Error with below message occured, anyone have meet similar problem ? Any clues how to interprete this message ? g ++ -I"D:/PROGRA~1/R/R-215~1.2/include" -DNDEBUG -I"D:/Program Files/R/R-2.15.2/library/Rcpp/include" -O2 -Wall -mtune=core2 -c filed946a0620c7.cpp -o

Getting RInside example to work with extra linker option -framework

做~自己de王妃 提交于 2020-01-05 03:55:10
问题 I got the RInside example to run and work but I had to manually add the linker option: "-F/Library/Frameworks/R.framework/.. -framework R" at the end for g++ (on Mac Snow Leopard 10.6.8 with Xcode 3.x). It works, but I don't know why. Can anyone say what these options actually do ? I could not find it on this list: http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html Here is the original code: #include <RInside.h> // for the embedded R via RInside int main(int argc, char *argv[]) { RInside R

How do I see and replicate the R default Makevars configuration?

本秂侑毒 提交于 2020-01-05 01:59:25
问题 I do not have a ~/.R/Makevars file and > tools::makevars_user() character(0) > tools::makevars_site() character(0) Yet, R must be reading the configuration from somewhere as .cpp files containing Rcpp exports in the package src subdirectory compile fine. I am interested to know how to write a Makefile.win in the src directory so that Rcpp files continue to compile, alongside TMB .cpp files. Currently a makefile like: all: fn1.dll fn2.dll fn1.dll: fn1.cpp Rscript --vanilla -e "TMB::compile(

How do I see and replicate the R default Makevars configuration?

不羁岁月 提交于 2020-01-05 01:59:12
问题 I do not have a ~/.R/Makevars file and > tools::makevars_user() character(0) > tools::makevars_site() character(0) Yet, R must be reading the configuration from somewhere as .cpp files containing Rcpp exports in the package src subdirectory compile fine. I am interested to know how to write a Makefile.win in the src directory so that Rcpp files continue to compile, alongside TMB .cpp files. Currently a makefile like: all: fn1.dll fn2.dll fn1.dll: fn1.cpp Rscript --vanilla -e "TMB::compile(

Cannot compile from source with Rcpp on Windows 7

半腔热情 提交于 2020-01-04 05:35:08
问题 I am running a new installation of R 3.3 on a Windows 7 virtual machine, and trying to install my own R package that uses Rcpp. The package is available on GitHub. I have installed Rtools and both Rcpp and devtools Using devtools::install_github("pbsag/tcadr") : > devtools::install_github("pbsag/tcadr") Downloading GitHub repo pbsag/tcadr@master from URL https://api.github.com/repos/pbsag/tcadr/zipball/master Installing tcadr "C:/PROGRA~1/R/R-33~1.0/bin/x64/R" --no-site-file --no-environ --no

QR decomposition in RcppArmadillo

给你一囗甜甜゛ 提交于 2020-01-04 04:06:26
问题 Really confused why the QR output using RcppArmadillo is different than QR output from R; Armadillo documentation doesnt give a clear answer either. Essentially when I give R a matrix Y that is n * q (say 1000 X 20 ) , I get back Q which is 1000 X 20 and R 20 X 1000. This is what I need. But when I use the QR solver in Armadillo, it throws me back Q 1000 X 1000 and R 1000 X 20. Can I call R's qr function instead? I need Q to have dimension n x q, not q x q. Code below is what I am using(its a