📜  在java代码示例中计算百分位数

📅  最后修改于: 2022-03-11 14:52:06.385000             🧑  作者: Mango

代码示例2
public static long[] percentiles(long[] latencies, double... percentiles) {
    Arrays.sort(latencies, 0, latencies.length);
    long[] values = new long[percentiles.length];
    for (int i = 0; i < percentiles.length; i++) {
      int index = (int) (percentiles[i] * latencies.length);
      values[i] = latencies[index];
    }
    return values;
  }