R/development/review/parallel_detect_outliers.R

Defines functions detect_outlier

ncx <- detectCores()
cl <- makeCluster(ncx)

detect_outlier <- function(nvec, cl, ncx){
  tot <- length(nvec)
  eachN <- ceiling(tot/ncx)

  ninjar::print_stamp("splitting vector")
  pll_vec <- parallel::clusterSplit(cl, nvec)

  ninjar::print_stamp("Calculating...")
  clusterApply(cl, pll_vec, quantile)
}

nvec <- rnorm(100000000)
ninjar::RunTimer(quantile(nvec))
ninjar::RunTimer(detect_outlier(nvec, cl, ncx))
stopCluster(cl)
bfatemi/ninjar documentation built on Sept. 8, 2019, 7:37 p.m.