public static long getPercentile(LongArrayList nums, double phi) {
    if (nums.isEmpty()) {
      throw new NoSuchElementException();
    } else {
      nums.sortThis();
      return nums.get((int) Math.ceil(nums.size() * phi));
    }
  }
Util for computing median, MAD, percentile.
library-udf/src/main/java/org/apache/iotdb/library/dprofile/util/ExactOrderStatistics.java