Here you can find the source of maximum(List
Parameter | Description |
---|---|
sortedDataAscendingOrder | a parameter |
public final static Double maximum(List<Double> sortedDataAscendingOrder)
//package com.java2s; //License from project: LGPL import java.util.List; public class Main { /**/*from w w w. ja v a 2 s . co m*/ * Get the maximum value thru linear interpolations * * @param sortedDataAscendingOrder * @return Double */ public final static Double maximum(List<Double> sortedDataAscendingOrder) { return interpolateLinearlyQuantile(sortedDataAscendingOrder, (double) 1); } /** * Interpolate linearly an quantile * * Inspired on: http://msenux.redwoods.edu/math/R/boxplot.php * * @param sortedDataAscendingOrder sorted data in ascending order (NOT NULL) * @param p percentage * @return Double interpolated linearly quantile */ private final static Double interpolateLinearlyQuantile(List<Double> sortedDataAscendingOrder, Double p) { int n = sortedDataAscendingOrder.size(); double position = (1 + (p * (n - 1))); int leftIndex = (int) Math.floor(position) - 1; int rightIndex = (int) Math.ceil(position) - 1; Double quantile; if (leftIndex == rightIndex) { quantile = sortedDataAscendingOrder.get(leftIndex); } else { Double leftIndexValue = sortedDataAscendingOrder.get(leftIndex); Double rightIndexValue = sortedDataAscendingOrder.get(rightIndex); quantile = leftIndexValue + 0.5 * (rightIndexValue - leftIndexValue); } return quantile; } }