Java Utililty Methods List Median

List of utility methods to do List Median

Description

The list of methods to do List Median are organized into topic(s).

Method

doublemedian(ArrayList values)
median
double[] arr = new double[values.size()];
for (int ii = 0; ii < arr.length; ii++) {
    arr[ii] = values.get(ii);
return median(arr);
Tmedian(final List array)
Compute the median element of the list of integers
if (array == null)
    throw new IllegalArgumentException("Array must be non-null");
final int size = array.size();
if (size == 0)
    throw new IllegalArgumentException("Array cannot have size 0");
else if (size == 1)
    return array.get(0);
else {
...
doublemedian(List data)
median
ArrayList<Double> sorted = new ArrayList<Double>(data.size());
for (int i = 0; i < data.size(); i++) {
    sorted.add(data.get(i).doubleValue());
Collections.sort(sorted);
if (sorted.size() % 2 == 1) {
    return sorted.get(sorted.size() / 2);
} else {
...
Doublemedian(List list)
This method returns you the median value for a List of Doubles
Collections.sort(list);
int middle = list.size() / 2; 
if (list.size() % 2 == 1) {
    return list.get(middle);
} else {
    return (list.get(middle - 1) + list.get(middle)) / 2.0;
doublemedian(List list)
median
Collections.sort(list);
int i = list.size() / 2;
if (list.size() % 2 == 1)
    return list.get(i);
return (list.get(i) + list.get(i + 1)) / 2;
doublemedian(List p)
median
Double[] b = new Double[p.size()];
int i = 0;
for (Double entry : p) {
    b[i] = entry;
    i++;
Arrays.sort(b);
if (p.size() % 2 == 0) {
...
Doublemedian(List sortedDataAscendingOrder)
Get the median value thru linear interpolations
return interpolateLinearlyQuantile(sortedDataAscendingOrder, 0.50);
Doublemedian(List list)
median
Random r = new Random(list.size());
if (0 == (list.size() % 2)) { 
    return (medianHelper(list, list.size() / 2, r) + medianHelper(list, list.size() / 2 + 1, r)) / 2.0;
} else {
    return (double) medianHelper(list, list.size() / 2 + 1, r);
Tmedian(List data)
median
Collections.sort((List) data);
int n = data.size();
return data.get(n / 2);
Ymedian(List data)
median
Collections.sort(data);
return data.get(data.size() / 2);