Eno <- function(obs, posdim, parallel = FALSE, ncores = NULL) {
  dimsvar <- dim(obs)
  if (is.null(dimsvar)) {
    dimsvar <- length(obs)
  }
  if (!is.null(dim(obs))) {
    eno <- Apply(data = list(obs), margins = list(c(1 : length(dim(obs)))[-posdim]), 
                 AtomicFun = ".Eno", parallel = parallel, ncores = ncores)
    effnumobs <- adrop(eno, 1)
  } else {
    effnumobs <- .Eno(obs)
  }
  return(effnumobs)
}

.Eno <- function(obs) {
  n <- length(sort(obs))
  a <- acf(obs, lag.max = n - 1, plot = FALSE, 
           na.action = na.pass)$acf[2:n, 1, 1]
  s <- 0 
  for (k in 1:(n - 1)) {
    s <- s + (((n - k) / n) * a[k])
  }
  eno <- min(n / (1 + (2 * s)), n)
}

