a <- sin(0.1*seq(100))
a[20] <- 50
b <- roll_hampel(a,10)
threshold <- 6
which(b > threshold)
if (FALSE) {
require(microbenchmark)
require(pracma)
microbenchmark(hampel(a,10), roll_hampel(a,10), times=10)
# Unit: microseconds
# expr min lq median uq max neval
# hampel(a, 10) 7610.688 7784.374 8037.4035 9453.928 16176.535 10
# roll_hampel(a, 10) 36.530 37.443 58.7165 65.418 90.403 10
}
Run the code above in your browser using DataLab