changeset 2646:c11da3540b70

Checked in out dated version of outlier test. flys-artifacts/trunk@4301 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 25 Apr 2012 16:04:37 +0000
parents 4f7d1ea38404
children 4b7a28e81643
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/Outlier.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FileUploadService.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java
diffstat 4 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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	<sascha.teichmann@intevation.de>
+
+	* 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	<sascha.teichmann@intevation.de>
 
 	* 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);
+            }
         }
 
 
--- 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;
 
--- 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;

http://dive4elements.wald.intevation.org