/*
Returns the index of the median of the three indexed integers.
187422
private static int med3(Quicksortable q, int a, int b, int c) {
        return (q.compare(a, b) < 0 ?
                (q.compare(b, c) < 0 ? b : q.compare(a, c) < 0 ? c : a) :
                (q.compare(b, c) > 0 ? b : q.compare(a, c) > 0 ? c : a));
    }
1332953
public static int min(IntArrayND array)
    {
        return array.stream().parallel().reduce(
            Integer.MAX_VALUE, Math::min);
    }
932664
def median(self):
        
        return round(float(np.median(self.array)), self.precision)\
            if len(self.array) else None
217699
private int choose_pivot(int p, int n) {
        int pl, pm, pn;// pointers
        int s;

        pm = p + (n >> 1); /* small arrays, middle element. */
        if (n > 7) {
            pl = p;
            pn = p + n - 1;
            if (n > 40) { /* big arrays, pseudomedian of 9. */
                s = n >> 3;
                pl = MED3(pl, pl + s, pl + s + s);
                pm = MED3(pm - s, pm, pm + s);
                pn = MED3(pn - s - s, pn - s, pn);
            }
            pm = MED3(pl, pm, pn); /* midsize arrays, median of 3. */
        }
        return KEY(pm);
    }
281563
public static float median(final float a, final float b, final float c) {
        int ab = Float.compare(a, b);
        int ac = Float.compare(a, c);
        int bc = 0;

        if ((ab >= 0 && ac <= 0) || (ac >= 0 && ab <= 0)) {
            return a;
        } else if ((((bc = Float.compare(b, c)) <= 0) && ab <= 0) || (bc >= 0 && ab >= 0)) {
            return b;
        } else {
            return c;
        }
    }
507091
public static <T> T median(List<? extends T> data, Comparator<? super T> comparator) {
    return median(data, comparator, 0, data.size());
  }
226554
public static double median(FlatDataCollection flatDataCollection) {
        double[] doubleArray = flatDataCollection.stream().filter(x -> x!=null).mapToDouble(TypeInference::toDouble).toArray();
        int n = doubleArray.length;
        if(n==0) {
            throw new IllegalArgumentException("The provided collection can't be empty.");
        }
        Arrays.sort(doubleArray);
        
        double median;
        if(n%2==0) {
            median = (doubleArray[n/2 - 1] + doubleArray[n/2])/2.0;
        }
        else {
            median = doubleArray[n/2];
        }
        
        return median;
    }
296338
public static <T> T median(final T[] a, Comparator<? super T> cmp) {
        N.checkArgNotNullOrEmpty(a, "The spcified array 'a' can not be null or empty");

        return median(a, 0, a.length, cmp);
    }
954425
public static <T> Collector<T, ?, Optional<T>> median(Comparator<? super T> comparator) {
        return percentile(0.5, comparator);
    }
1045695
function() {
			// Get the median and the range that the number must fall within
			var median = this.median();
			var range  = this.iqr() * 1.5;

			// Create a new stats object to hold the outliers
			var outliers = stats([]);

			// Go through each element in the data set and test to see if it
			// is an outlier
			this.each(function(num) {
				if (Math.abs(num - median) > range) {
					// The number is an outlier
					outliers.push(num);
				}
			});

			return outliers;
		}
890356
public static <T extends Comparable<? super T>> T median(T[] a) {
        return QuickSelect.median(a);
    }
654626
def fast_median(a):
    
    a = checkma(a)
    #return scoreatpercentile(a.compressed(), 50)
    if a.count() > 0:
        out = np.percentile(a.compressed(), 50)
    else:
        out = np.ma.masked
    return out
1040527
public static <T, U> Collector<T, ?, Optional<U>> median(Function<? super T, ? extends U> function, Comparator<? super U> comparator) {
        return percentile(0.5, function, comparator);
    }
940950
public static int selectIndex( float []data , int k , int maxIndex ,  int []indexes) {

		for( int i = 0; i < maxIndex; i++ ) {
			indexes[i] = i;
		}

		int i,j,mid;
		int n = maxIndex;
		int a;
		int l = 0;
		int ir = n-1;

		int temp;

		for(;;) {
			if( ir <= l+1 ) {
				if( ir == l+1 && data[indexes[ir]] < data[indexes[l]] ) {
					temp = indexes[l];
					indexes[l] = indexes[ir];
					indexes[ir] = temp;
				}
				return indexes[k];
			} else {
				mid = (l+ir) >> 1;

				int lp1 = l+1;
				temp = indexes[mid];
				indexes[mid] = indexes[lp1];
				indexes[lp1] = temp;

				if( data[indexes[l]] > data[indexes[ir]] ) {
					temp = indexes[l];
					indexes[l] = indexes[ir];
					indexes[ir] = temp;
				}

				if( data[indexes[lp1]] > data[indexes[ir]] ) {
					temp = indexes[lp1];
					indexes[lp1] = indexes[ir];
					indexes[ir] = temp;
				}

				if( data[indexes[l]] > data[indexes[lp1]] ) {
					temp = indexes[lp1];
					indexes[lp1] = indexes[l];
					indexes[l] = temp;
				}

				i=lp1;
				j=ir;
				a=indexes[lp1];

				for(;;) {
					do i++; while(data[indexes[i]]<data[a]);
					do j--; while (data[indexes[j]]>data[a]);
					if( j < i) break;
					temp = indexes[i];
					indexes[i] = indexes[j];
					indexes[j] = temp;
				}
				indexes[lp1] = indexes[j];
				indexes[j] = a;
				if( j >= k ) ir=j-1;
				if( j <= k ) l=i;
			}
		}
	}
110156
@SuppressWarnings("unchecked")
    public static int median(List<Integer> values) {
        if (values == null || values.isEmpty()) return 0;

        values = new ArrayList<Integer>(values);
        Collections.sort(values);

        final int size = values.size();
        final int sizeHalf = size / 2;
        if (size % 2 == 1) { //is odd?
            // 0 1 [2] 3 4: size/2 = 5/2 = 2.5 -> 2
            return values.get(sizeHalf);
        }

        // 0 1 [2 3] 4 5: size/2 = 6/2 = 3
        return (values.get(sizeHalf - 1) + values.get(sizeHalf)) / 2;
    }
551440
def median(data):
    """"""
    data.sort()
    num_values = len(data)
    half = num_values // 2
    if num_values % 2:
        return data[half]
    return 0.5 * (data[half-1] + data[half])
96493
public int[] getElementIndices() {
        Integer[] indices = indexToValue.keySet().toArray(new Integer[0]);
        int[] primitive = new int[indices.length];
        for (int i = 0; i < indices.length; ++i)
            primitive[i] = indices[i].intValue();
        return primitive;
    }