Java List Median getMedian(List results)

Here you can find the source of getMedian(List results)

Description

get Median

License

Open Source License

Declaration

public static double getMedian(List<Double> results) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collections;
import java.util.List;

public class Main {
    public static double getMedian(List<Double> results) {
        Collections.sort(results);
        if (results.size() % 2 == 0)
            return ((double) results.get(results.size() / 2) + (double) results.get(results.size() / 2 - 1)) / 2;
        else/*from  w ww. ja  v  a  2s .  co  m*/
            return (double) results.get(results.size() / 2);
    }
}

Related

  1. calculateMedian(List values, boolean copyAndSort)
  2. getGeneMedian(final List doubleArray)
  3. getMedian(Collection list)
  4. getMedian(List list)
  5. getMedian(List numbers)
  6. getMedianValue(List nums)
  7. median(ArrayList values)
  8. median(final List array)
  9. median(List data)