Here you can find the source of median3(double[] v)
private static double median3(double[] v)
//package com.java2s; //License from project: Open Source License public class Main { private static double median3(double[] v) { sortInPlace(v, 0, 1);//from ww w.j a v a 2 s. c o m sortInPlace(v, 1, 2); sortInPlace(v, 0, 1); return v[1]; } private static int median3(int[] v) { sortInPlace(v, 0, 1); sortInPlace(v, 1, 2); sortInPlace(v, 0, 1); return v[1]; } private static void sortInPlace(final double[] v, final int i, final int j) { if (v[i] > v[j]) { final double tmp = v[i]; v[i] = v[j]; v[j] = tmp; } } private static void sortInPlace(final int[] v, final int i, final int j) { if (v[i] > v[j]) { final int tmp = v[i]; v[i] = v[j]; v[j] = tmp; } } }