Here you can find the source of median(double[] data)
Taken from https://stackoverflow.com/questions/7988486/how-do-you-calculate-the-variance-median-and-standard-deviation-in-c-or-java Mr.
Parameter | Description |
---|---|
data | to get the median |
public static double median(double[] data)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { /**/* w w w.j a v a 2 s. c o m*/ * Taken from * https://stackoverflow.com/questions/7988486/how-do-you-calculate-the-variance-median-and-standard-deviation-in-c-or-java * Mr. White's answer * * @param data * to get the median * @return the median */ public static double median(double[] data) { Arrays.sort(data); if (data.length % 2 == 0) { return (data[(data.length / 2) - 1] + data[data.length / 2]) / 2.0; } return data[data.length / 2]; } }