function _mean(array) {
    var sum = 0;
    var num = 0;
    deepForEach(array, function (value) {
      try {
        sum = add(sum, value);
        num++;
      } catch (err) {
        throw improveErrorMessage(err, 'mean', value);
      }
    });

    if (num === 0) {
      throw new Error('Cannot calculate mean of an empty array');
    }

    return divide(sum, num);
  }
Recursively calculate the mean value in an n-dimensional array
@param {Array} array
@return {number} mean
@private