Here you can find the source of median(double[][] values)
public static double median(double[][] values)
//package com.java2s; //License from project: Apache License public class Main { public static double median(double[][] values) { double[] flatvalues = new double[values.length * values.length]; for (int i = 0; i < values.length; i++) { for (int j = 0; j < values.length; j++) { flatvalues[i * values.length + j] = values[i][j]; }/*from w ww. j ava2 s .c om*/ } if (flatvalues.length % 2 == 0) return flatvalues[flatvalues.length / 2]; int lowerindex = flatvalues.length / 2; int upperindex = flatvalues.length / 2 + 1; return (flatvalues[lowerindex] + flatvalues[upperindex]) / 2; } }