List of utility methods to do Median
double[] | medianFilter(double[] array, int window) median Filter int len = array.length; if (window > len) { return null; int mid = window / 2; double[] result = new double[len]; double[] subarray; for (int i = 0; i < len; i++) { ... |
int | medianFromHistogram(int[] hist) median From Histogram int pos_l = 0, pos_r = hist.length - 1; int sum_l = hist[pos_l], sum_r = hist[pos_r]; while (pos_l < pos_r) { if (sum_l < sum_r) { sum_l += hist[++pos_l]; } else { sum_r += hist[--pos_r]; return pos_l; |
int | medianIndexInSorted(double[] arr) median Index In Sorted Arrays.sort(arr); if (arr.length < 2) { return 0; } else if (arr.length % 2 == 0) { return (arr.length / 2); } else { return ((arr.length - 1) / 2); |
int | medianOfMedians(int[] array) Finds the median of medians in the given array. final int splitSize = array.length / 5; if (splitSize <= 2) { radixSort(array); return array[array.length / 2]; int[] pivots = new int[splitSize]; for (int i = 0; i < splitSize; i++) { final int start = i * 5; ... |