Here you can find the source of getGeneMedian(final List
public static double getGeneMedian(final List<Double> doubleArray)
//package com.java2s; /*/*from w w w.j ava2 s.c om*/ * Nividic development code * * This code may be freely distributed and modified under the * terms of the GNU Lesser General Public Licence. This should * be distributed with the code. If you do not have a copy, * see: * * http://www.gnu.org/copyleft/lesser.html * * Copyright for this code is held jointly by the microarray platform * of the ?cole Normale Sup?rieure and the individual authors. * These should be listed in @author doc comments. * * For more information on the Nividic project and its aims, * or to join the Nividic mailing list, visit the home page * at: * * http://www.transcriptome.ens.fr/nividic * */ import java.util.Collections; import java.util.List; public class Main { public static double getGeneMedian(final List<Double> doubleArray) { Collections.sort(doubleArray); Double median; if (doubleArray.size() == 1) return doubleArray.get(0); int center = doubleArray.size() / 2; if (doubleArray.size() % 2 == 0) { final double a, b; a = doubleArray.get(center); b = doubleArray.get(center - 1); median = new Double((a + b) / 2); } else median = doubleArray.get(center); return median.doubleValue(); } }