Here you can find the source of median(double[] arr)
public static double median(double[] arr)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static double median(double[] arr) { if (arr == null || arr.length == 0) return Double.NaN; int l = arr.length; Arrays.sort(arr);/* w w w . ja v a 2s. co m*/ return arr[(int) Math.floor(l / 2.0)] / 2 + arr[(int) Math.ceil(l / 2.0)] / 2; } }