search for: median2

Displaying 2 results from an estimated 2 matches for "median2".

Did you mean: median
2003 Oct 29
3
long algo
...ctical and straight forward. However (the inevitable however), I am finding it very slow for one of my operations: it s basically an itertation over i and j in a pretty big table (4* 4608). It takes 30 minutes!!!! Thanks Ps:if it can help here is the source: median1<-matrix(nrow=4608,ncol=1) median2<-matrix(nrow=4608,ncol=1) median3<-matrix(nrow=4608,ncol=1) median4<-matrix(nrow=4608,ncol=1) v<-c(18,19,20,21,23) for (i in 0:11) { for (j in 1:384) { median1[j+(i*384),]<-puce[j+(i*384),5]+median(puce[v+384*i,2]-puce[v+384*i,5]) median2[j+(i*...
2006 Apr 10
2
Suggestions to speed up median() and has.na()
...environment: namespace:stats> Suggestion 1: Replace the sort() calls with the .Internal(psort(x, partial)). This will avoid unnecessary overhead, especially an expensive second check for NAs using any(is.na(x)). Simple benchmarking with x <- rnorm(10e6) system.time(median(x))/system.time(median2(x)) where median2() is the function with the above replacements, gives about 20-25% speed up. Suggestion 2: Create a has.na(x) function to replace any(is.na(x)) that returns TRUE as soon as a NA value is detected. In the best case it returns after the first index with TRUE, in the worst case it...