Java List Difference getScoreSeriesByMinMaxAndDiff(List percentClaimedHistory)

Here you can find the source of getScoreSeriesByMinMaxAndDiff(List percentClaimedHistory)

Description

get Score Series By Min Max And Diff

License

Apache License

Declaration

public static double getScoreSeriesByMinMaxAndDiff(List<Integer> percentClaimedHistory) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static double getScoreSeriesByMinMaxAndDiff(List<Integer> percentClaimedHistory) {
        Integer first = percentClaimedHistory.get(0);
        Integer current = percentClaimedHistory.get(percentClaimedHistory.size() - 1);
        int diff = current.intValue() - first.intValue();
        double score = diff * Math.pow(retrieveMinimumNotZeroDifference(percentClaimedHistory), -1);
        return score;
    }//ww  w  .  j ava  2 s .  co m

    private static int retrieveMinimumNotZeroDifference(List<Integer> percentClaimedHistory) {
        // Let's assume the higher difference
        int minimumDifference = 100;
        for (int i = 0; i < percentClaimedHistory.size(); i++) {
            Integer outerPercent = percentClaimedHistory.get(i);
            for (int j = 0; j < percentClaimedHistory.size(); j++) {
                Integer innerPercent = percentClaimedHistory.get(j);
                int currentDifference = Math.abs(outerPercent - innerPercent);
                if (currentDifference != 0 && currentDifference < minimumDifference) {
                    minimumDifference = currentDifference;
                }
            }
        }
        return minimumDifference;
    }
}

Related

  1. getDiffentElement(List minList, List maxList)
  2. getDifference(List bigger, List smaller)
  3. getDiffInfo(List infoList)
  4. getLeftDiff(List list1, List list2)
  5. getListsDiffFormatted(List list0, List list1)
  6. hasRemoval(List differences, String path)
  7. maxDiffBetweenCompressedWayNodes(final List wayNodeOffsets)
  8. retrieveMinimumNotZeroDifference(List percentClaimedHistory)