Here you can find the source of getmedian(double[] vals, int nvalindex)
public static double getmedian(double[] vals, int nvalindex)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**/* www . j a va2 s . c o m*/ * Returns the median value in vals in indicies between 0 and nvalindex-1 */ public static double getmedian(double[] vals, int nvalindex) { double dmedian; Arrays.sort(vals, 0, nvalindex); if (nvalindex % 2 == 0) { dmedian = (vals[nvalindex / 2 - 1] + vals[nvalindex / 2]) / 2; } else { dmedian = vals[nvalindex / 2]; } return dmedian; } }