function _quantileSeq(array, prob, sorted) {
    var flat = flatten(array);
    var len = flat.length;

    if (len === 0) {
      throw new Error('Cannot calculate quantile of an empty sequence');
    }

    if (isNumber(prob)) {
      var _index = prob * (len - 1);

      var _fracPart = _index % 1;

      if (_fracPart === 0) {
        var value = sorted ? flat[_index] : partitionSelect(flat, _index);
        validate(value);
        return value;
      }

      var _integerPart = Math.floor(_index);

      var _left;

      var _right;

      if (sorted) {
        _left = flat[_integerPart];
        _right = flat[_integerPart + 1];
      } else {
        _right = partitionSelect(flat, _integerPart + 1); // max of partition is kth largest

        _left = flat[_integerPart];

        for (var i = 0; i < _integerPart; ++i) {
          if (compare(flat[i], _left) > 0) {
            _left = flat[i];
          }
        }
      }

      validate(_left);
      validate(_right); // Q(prob) = (1-f)*A[floor(index)] + f*A[floor(index)+1]

      return add(multiply(_left, 1 - _fracPart), multiply(_right, _fracPart));
    } // If prob is a BigNumber


    var index = prob.times(len - 1);

    if (index.isInteger()) {
      index = index.toNumber();

      var _value = sorted ? flat[index] : partitionSelect(flat, index);

      validate(_value);
      return _value;
    }

    var integerPart = index.floor();
    var fracPart = index.minus(integerPart);
    var integerPartNumber = integerPart.toNumber();
    var left;
    var right;

    if (sorted) {
      left = flat[integerPartNumber];
      right = flat[integerPartNumber + 1];
    } else {
      right = partitionSelect(flat, integerPartNumber + 1); // max of partition is kth largest

      left = flat[integerPartNumber];

      for (var _i3 = 0; _i3 < integerPartNumber; ++_i3) {
        if (compare(flat[_i3], left) > 0) {
          left = flat[_i3];
        }
      }
    }

    validate(left);
    validate(right); // Q(prob) = (1-f)*A[floor(index)] + f*A[floor(index)+1]

    var one = new fracPart.constructor(1);
    return add(multiply(left, one.minus(fracPart)), multiply(right, fracPart));
  }
Calculate the prob order quantile of an n-dimensional array.

@param {Array} array
@param {Number, BigNumber} prob
@param {Boolean} sorted
@return {Number, BigNumber, Unit} prob order quantile
@private