r - Problems with sum functions -
using other programming language accelerate r big innovation, seems hazardous well. statistic function had stable use, given same result same entry such sum
, sd
, cor
... problem have using big amount of data (10^8 sample). used rcpp , rcppparallel version of sum demonstrate bugs big data.
#include <rcpp.h> using namespace rcpp; /******************************************************** * rcpp inner function :sum *******************************************************/ // [[rcpp::export]] double rcppsum(numericvector x) { return sum(x); } /*** r library("rcpp") library("rcppparallel") options(digits=22)# showing more details in number sourcecpp(system.file("tests/cpp/sum.cpp", package = "rcppparallel")) ## given 2 function parallelvectorsum (rcppparallel) , vectorsum (c++stl) ## manipulated big vector x<-rnorm(100000000) (rsum<-sum(x)) (rcpp<-rcppsum(x)) (rcppparallel<-parallelvectorsum(x)) (std<-vectorsum(x)) identical(rsum,rcpp) identical(std,rcpp) identical(rsum,rcppparallel) identical(rcpp,rcppparallel) ## simple checking of stability v<-0 for(i in 1:100)v[i]<-sum(x) (mean(v)) (sd(v)) ####stable sd =0 for(i in 1:100)v[i]<-vectorsum(x) (mean(v)) (sd(v)) ###stable sd =0 for(i in 1:100)v[i]<-rcppsum(x) (mean(v)) (sd(v)) ###stable sd =0 for(i in 1:100)v[i]<-parallelvectorsum(x) (mean(v)) (sd(v)) ##instable sd!=0 */
we can qualify parallel version unstable, excluded. result between rcpp , rsum truth?
briefly:
- conjecture alert: seems hazardous well. please or remove it.
- please show courtesy of proper capitalization. write
rcpp
,rcppparallel
, respectively. though guess refer labels doesn't matter. - using
options(digits=22)
cute useless. double precision gives around 16 digits. hoping more not give more.
Comments
Post a Comment