Java Median median(double[] l)

Here you can find the source of median(double[] l)

Description

median

License

Open Source License

Declaration

public static double median(double[] l) 

Method Source Code

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

import java.util.Arrays;

public class Main {
    public static double median(double[] l) {
        Arrays.sort(l);/* w  w  w.  ja  v a  2  s  .co m*/
        int middle = l.length / 2;
        if (l.length % 2 == 0) {
            double left = l[middle - 1];
            double right = l[middle];
            return (left + right) / 2;
        } else {
            return l[middle];
        }
    }
}

Related

  1. median(double[] array)
  2. median(double[] array)
  3. median(double[] data)
  4. median(double[] data, int length)
  5. median(double[] input)
  6. median(double[] unsorted)
  7. median(double[] v)
  8. median(double[] vals)
  9. median(double[] values)