Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/StdDevOutlier.java @ 4795:8ee270a3ef25
Small code cleanups in S/Q outlier tests.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 11 Jan 2013 22:16:22 +0100 |
parents | a7d080347ac3 |
children | 846b0441f905 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/StdDevOutlier.java Fri Jan 11 13:57:38 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/StdDevOutlier.java Fri Jan 11 22:16:22 2013 +0100 @@ -2,21 +2,12 @@ import java.util.List; -import org.apache.commons.math.MathException; - -import org.apache.commons.math.distribution.TDistributionImpl; - -import org.apache.commons.math.stat.descriptive.moment.Mean; import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; import org.apache.log4j.Logger; -import de.intevation.flys.artifacts.model.sq.SQ; - public class StdDevOutlier { - public static final double EPSILON = 1e-5; - public static final double DEFAULT_FACTOR = 3; private static Logger log = Logger.getLogger(StdDevOutlier.class); @@ -28,7 +19,11 @@ return findOutlier(values, DEFAULT_FACTOR, null); } - public static Integer findOutlier(List<Double> values, double factor, double[] stdDevResult) { + public static Integer findOutlier( + List<Double> values, + double factor, + double [] stdDevResult + ) { boolean debug = log.isDebugEnabled(); if (debug) { @@ -41,7 +36,7 @@ log.debug("Values to check: " + N); } - if (values.size() < 3) { + if (N < 3) { return null; } @@ -49,15 +44,13 @@ double maxValue = -Double.MAX_VALUE; int maxIndex = -1; - int ndx = 0; - for (int i = values.size()-1; i >= 0; --i) { + for (int i = N-1; i >= 0; --i) { double value = Math.abs(values.get(i)); stdDev.increment(value); if (value > maxValue) { maxValue = value; - maxIndex = ndx; + maxIndex = i; } - ++ndx; } double sd = stdDev.getResult(); @@ -69,9 +62,11 @@ log.debug("accepted: " + accepted); log.debug("max value: " + maxValue); } + if (stdDevResult != null) { stdDevResult[0] = sd; } + return maxValue > accepted ? maxIndex : null; } }