n<-100000
aa<-rnorm(n)
bb<-rnorm(n)
system.time(lapply(aa, function(z){mean(bb<pnorm(z))}))
It takes too long to run this small code. Simply put, I have two vectors aa
and bb
. For each element of aa
, say aa[i]
, I want the proportion of bb < aa[i]
I found this article and tried to use it to speed up. But it does not work. Speed comparison of sapply with a composite function
Any help will be appreciated!