#Multi-model, multi-category pool function (Weigel et. al., 2008)
Counts2Prob <- function(exp, model_dim = NULL, members_dim = NULL, bin_dim = NULL) {
  categories <- length(exp[bin_dim])
  if (is.null(members_dim)) {
    if ("member" %in% names(dim(exp))) {
      members_dim <- which(names(dim(exp)) == "member")
    } else {
      stop("members_dim must be specified")
    }
  }
  if (is.null(bin_dim)) {
    if ("bin" %in% names(dim(exp))) {
      bin_dim <- which(names(dim(exp)) == "bin")
    } else {
      stop("bin_dim must be specified")
    }
  }
  if (is.null(model_dim)) {
    exp <- aperm(array(exp, c(dim(exp), 1)), c(3, members_dim, bin_dim))
  } else {
    exp <- aperm(exp, c(model_dim, members_dim, bin_dim))
  }
  .pool_fun <- function(x) {
    sum(x) / length(x)
  }
  if (is.null(model_dim)) {
    probs <- aaply(exp, .margins = c(1, 3), .fun = .pool_fun, .drop = FALSE)
    probs <- adrop(probs, 1)
  } else if (!is.null(model_dim)) {
    probs <- aaply(exp, .margins = c(1, 3), .fun = .pool_fun)
    probs <- Mean1Dim(probs, 1)
  }
 return(probs)
}