public static long median(List<Long> values) {
    if (values.size() == 0) {
      throw new IllegalArgumentException("Median of an empty list is not defined.");
    }
    Collections.sort(values);
    int middle = values.size() / 2;
    if (values.size() % 2 == 0) {
      return (values.get(middle - 1) + values.get(middle)) / 2;
    } else {
      return values.get(middle);
    }
  }
Find the median of the given list

@param values The values
@return The median(values)
app/com/linkedin/drelephant/math/Statistics.java