Browse Source

反正切函数 兼容正负相关

dev_shibei_match
jianjun 5 years ago
parent
commit
bf214698a6
  1. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java
  2. 2
      epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java

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

2
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);

Loading…
Cancel
Save