# HG changeset patch # User Sascha L. Teichmann # Date 1335369877 0 # Node ID c11da3540b704731716f6e5bc713810a60e54a5d # Parent 4f7d1ea38404a6e2f5ba6d91c078ee6cca9dce41 Checked in out dated version of outlier test. flys-artifacts/trunk@4301 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 4f7d1ea38404 -r c11da3540b70 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed Apr 25 15:57:23 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed Apr 25 16:04:37 2012 +0000 @@ -1,3 +1,12 @@ +2012-04-25 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/math/Outlier.java: + Gah! Checked in out dated version. + + * src/main/java/de/intevation/flys/artifacts/services/FileUploadService.java, + src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java: + Removed superfluous imports. + 2012-04-25 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/math/Outlier.java: diff -r 4f7d1ea38404 -r c11da3540b70 flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/Outlier.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/Outlier.java Wed Apr 25 15:57:23 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/Outlier.java Wed Apr 25 16:04:37 2012 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.artifacts.math; +import org.apache.commons.math.MathException; + import org.apache.commons.math.stat.descriptive.moment.Mean; import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; @@ -8,8 +10,12 @@ import java.util.List; import java.util.ArrayList; +import org.apache.log4j.Logger; + public class Outlier { + private static Logger log = Logger.getLogger(Outlier.class); + public static class IndexedValue { protected int index; protected double value; @@ -71,7 +77,7 @@ double maxZ = -Double.MAX_VALUE; int iv = -1; - for (int i >= 0; i = N-1; --i) { + for (int i = N-1; i >= 0; --i) { IndexedValue v = values.get(i); double z = Math.abs(m - v.getValue())/s; if (z > maxZ) { @@ -80,11 +86,22 @@ } } - double t = Math.sqrt((N*(N-2)*z*z)/((N-1)*(N-1) - N*z*z)) + double t = Math.sqrt((N*(N-2)*maxZ*maxZ) + /((N-1)*(N-1) - N*maxZ*maxZ)); TDistributionImpl tdist = new TDistributionImpl(N-2); - double p = tdist.cumulativeProbability(t) + try { + double p = tdist.cumulativeProbability(t); + + if (p < alpha) { + outliers.add(values.get(iv)); + values.remove(iv); + } + } + catch (MathException me) { + log.error(me); + } } diff -r 4f7d1ea38404 -r c11da3540b70 flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FileUploadService.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FileUploadService.java Wed Apr 25 15:57:23 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FileUploadService.java Wed Apr 25 16:04:37 2012 +0000 @@ -3,7 +3,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.FileNotFoundException; import org.apache.log4j.Logger; diff -r 4f7d1ea38404 -r c11da3540b70 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java Wed Apr 25 15:57:23 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java Wed Apr 25 16:04:37 2012 +0000 @@ -1,6 +1,5 @@ package de.intevation.flys.artifacts.states; -import java.util.List; import java.io.File; import org.apache.log4j.Logger; @@ -16,7 +15,6 @@ import de.intevation.artifacts.common.utils.FileTools; import de.intevation.artifactdatabase.ProtocolUtils; -import de.intevation.artifactdatabase.state.Facet; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.resources.Resources;