@Test public void test_getPercentile_要素数2() { List<Long> list = Arrays.asList(new Long[] { 2L, 4L }); assertEquals(4L, MathUtil.getPercentile(list, 90, 0L)); }
public static long getPercentile(List<Long> longList, int p, long defaultValue) { if (longList == null || longList.isEmpty()) { return defaultValue; } if (p < 0 || p > 100) { return defaultValue; } int size = longList.size(); if (((long) size * (long) p) % 100L == 0) { int n = (int) (((long) size - 1L) * (long) p / 100L); long a = longList.get(n); long b = longList.get(n + 1); return (a + b) / 2L; } else { int n = (int) ((long) size * (long) p / 100L); if (n >= size) { n = size - 1; } return longList.get(n); } }
MathUtil { public static long getPercentile(List<Long> longList, int p, long defaultValue) { if (longList == null || longList.isEmpty()) { return defaultValue; } if (p < 0 || p > 100) { return defaultValue; } int size = longList.size(); if (((long) size * (long) p) % 100L == 0) { int n = (int) (((long) size - 1L) * (long) p / 100L); long a = longList.get(n); long b = longList.get(n + 1); return (a + b) / 2L; } else { int n = (int) ((long) size * (long) p / 100L); if (n >= size) { n = size - 1; } return longList.get(n); } } }
MathUtil { public static long getPercentile(List<Long> longList, int p, long defaultValue) { if (longList == null || longList.isEmpty()) { return defaultValue; } if (p < 0 || p > 100) { return defaultValue; } int size = longList.size(); if (((long) size * (long) p) % 100L == 0) { int n = (int) (((long) size - 1L) * (long) p / 100L); long a = longList.get(n); long b = longList.get(n + 1); return (a + b) / 2L; } else { int n = (int) ((long) size * (long) p / 100L); if (n >= size) { n = size - 1; } return longList.get(n); } } private  MathUtil(); }
MathUtil { public static long getPercentile(List<Long> longList, int p, long defaultValue) { if (longList == null || longList.isEmpty()) { return defaultValue; } if (p < 0 || p > 100) { return defaultValue; } int size = longList.size(); if (((long) size * (long) p) % 100L == 0) { int n = (int) (((long) size - 1L) * (long) p / 100L); long a = longList.get(n); long b = longList.get(n + 1); return (a + b) / 2L; } else { int n = (int) ((long) size * (long) p / 100L); if (n >= size) { n = size - 1; } return longList.get(n); } } private  MathUtil(); static long getSum(List<Long> longList); static long getAverage(List<Long> longList, long sum, long devByZero); static long getStandardDeviation(List<Long> longList, long average, long devByZero); static double getRate(long numerator, long denominator, double devByZeroValue); static long getMedian(List<Long> longList, long defaultValue); static long getPercentile(List<Long> longList, int p, long defaultValue); }
MathUtil { public static long getPercentile(List<Long> longList, int p, long defaultValue) { if (longList == null || longList.isEmpty()) { return defaultValue; } if (p < 0 || p > 100) { return defaultValue; } int size = longList.size(); if (((long) size * (long) p) % 100L == 0) { int n = (int) (((long) size - 1L) * (long) p / 100L); long a = longList.get(n); long b = longList.get(n + 1); return (a + b) / 2L; } else { int n = (int) ((long) size * (long) p / 100L); if (n >= size) { n = size - 1; } return longList.get(n); } } private  MathUtil(); static long getSum(List<Long> longList); static long getAverage(List<Long> longList, long sum, long devByZero); static long getStandardDeviation(List<Long> longList, long average, long devByZero); static double getRate(long numerator, long denominator, double devByZeroValue); static long getMedian(List<Long> longList, long defaultValue); static long getPercentile(List<Long> longList, int p, long defaultValue);  }