Java Median median(double[] arr)

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

Description

median

License

Open Source License

Declaration

public static double median(double[] arr) 

Method Source Code


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

import java.util.*;

public class Main {
    public static double median(double[] arr) {
        if (arr == null || arr.length == 0)
            return Double.NaN;
        int l = arr.length;
        Arrays.sort(arr);/*  w w w .  ja v a  2s.  co m*/
        return arr[(int) Math.floor(l / 2.0)] / 2 + arr[(int) Math.ceil(l / 2.0)] / 2;
    }
}

Related

  1. median(ArrayList values)
  2. Median(ArrayList values)
  3. median(double... a)
  4. median(double[] a)
  5. median(double[] a)
  6. median(double[] array)
  7. median(double[] array)
  8. median(double[] data)
  9. median(double[] data, int length)