How can I use qnorm on Rcpp?

岁酱吖の 提交于 2019-11-29 14:30:59

By making the mean and sd arguments double as the error message shows -- so try this is a full example

library(inline)
f <- cxxfunction(signature(xs="numeric", plugin="Rcpp", body='
     Rcpp::NumericVector x(xs);
     return Rcpp::wrap(Rcpp::qnorm(x, 1.0, 0.0));
')

and have a look at the examples and unit tests -- I just looked this up in the unit test file runit.stats.R which has a lot of test cases for these statistical 'Rcpp sugar' functions.

Edit on 2012-11-14: With Rcpp 0.10.0 released today, you can call do the signature R::qnorm(double, double, double, int, int) if you want to use C-style code written against Rmath.h. Rcpp sugar still gives you vectorised versions.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!