function _nmeanDim(array, dim) {
    try {
      var sum = reduce(array, dim, add);
      var s = Array.isArray(array) ? size(array) : array.size();
      return divide(sum, s[dim]);
    } catch (err) {
      throw improveErrorMessage(err, 'mean');
    }
  }
Calculate the mean value in an n-dimensional array, returning a
n-1 dimensional array
@param {Array} array
@param {number} dim
@return {number} mean
@private