Java List Sort maximum(List sortedDataAscendingOrder)

Here you can find the source of maximum(List sortedDataAscendingOrder)

Description

Get the maximum value thru linear interpolations

License

LGPL

Parameter

Parameter Description
sortedDataAscendingOrder a parameter

Return

Double

Declaration

public final static Double maximum(List<Double> sortedDataAscendingOrder) 

Method Source Code


//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;
    }
}

Related

  1. isSortedDescending(List list)
  2. isStringListSortedDesc(List list)
  3. isUnsortedEventsMatch(List actual, List expected)
  4. ListToSortedArray(List list)
  5. mapTosortedScoreList(HashMap unSortedMap)
  6. mergeLong(List l1, List l2, boolean sort)
  7. mergeSort(List m)
  8. mergeSort(List list)
  9. mergeSortedLists(List dest, List[] src, boolean removeDuplicates)