diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java index 75e78ea215..b4f2fd4677 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java @@ -1,5 +1,6 @@ package com.epmet.support.normalizing.batch; +import com.epmet.support.normalizing.Correlation; import com.epmet.support.normalizing.ScoreCalculator; import java.math.BigDecimal; @@ -70,9 +71,13 @@ public class BatchScoreCalculator { if (maxValue.compareTo(minValue) == 0) { //*((max-min)/ (Math.PI/2))+min //Math.atan(new Double(vo.getSampleValue().toString()))* - normalizeValue = new BigDecimal(Math.atan(new Double(vo.getSampleValue().toString()))) + normalizeValue = new BigDecimal(Math.atan(new Double(getFinalSampleValue(vo.getSampleValue(), threshold).toString()))) .multiply( (maxValue.subtract(minValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.UNNECESSARY))).add(minValue).setScale(6, RoundingMode.HALF_UP); + // + if (scoreCalculator.getCorrelation().getCode().equals(Correlation.NEGATIVE)) { + normalizeValue = maxValue.subtract(normalizeValue); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java b/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java index ff0811d4c5..408f837691 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java +++ b/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java @@ -20,7 +20,7 @@ public class MathUtilTest { BigDecimal maxValue = new BigDecimal(100); BigDecimal minValue = new BigDecimal(60); - BigDecimal normalizeValue = new BigDecimal(Math.atan(new Double("4"))) + BigDecimal normalizeValue = new BigDecimal(Math.atan(new Double("0"))) .multiply( (maxValue.subtract(minValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP))).add(minValue).setScale(6, RoundingMode.HALF_UP); System.out.println(normalizeValue);