changeset 3107:cbf308f5c41b

FixA: Store the standard deviation of delta Ws of reference points into parameters, too. flys-artifacts/trunk@4706 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 19 Jun 2012 15:28:40 +0000
parents 23de6d678fba
children 2d4d9050b1c6
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java
diffstat 3 files changed, 35 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Jun 19 14:01:47 2012 +0000
+++ b/flys-artifacts/ChangeLog	Tue Jun 19 15:28:40 2012 +0000
@@ -1,3 +1,12 @@
+2012-06-19	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java:
+	  Calculate the standard deviation of the delta Ws of the referencen points, too.
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java:
+	  Store the standard deviation of delta Ws of reference points into
+	  a parameters column "std-dev".
+
 2012-06-19  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/jfree/JFreeUtil.java: New function to
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java	Tue Jun 19 14:01:47 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java	Tue Jun 19 15:28:40 2012 +0000
@@ -1,11 +1,16 @@
 package de.intevation.flys.artifacts.model.fixings;
 
+import de.intevation.flys.artifacts.math.Outlier.IndexedValue;
+import de.intevation.flys.artifacts.math.Outlier.Outliers;
+
+import de.intevation.flys.artifacts.math.Outlier;
+
 import de.intevation.flys.artifacts.math.fitting.Function;
 
-import de.intevation.flys.artifacts.math.Outlier;
+import gnu.trove.TDoubleArrayList;
 
-import de.intevation.flys.artifacts.math.Outlier.IndexedValue;
-import de.intevation.flys.artifacts.math.Outlier.Outliers;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.commons.math.MathException;
 
@@ -13,13 +18,10 @@
 
 import org.apache.commons.math.optimization.general.LevenbergMarquardtOptimizer;
 
-import gnu.trove.TDoubleArrayList;
+import org.apache.commons.math.stat.descriptive.moment.StandardDeviation;
 
 import org.apache.log4j.Logger;
 
-import java.util.ArrayList;
-import java.util.List;
-
 public class Fitting
 {
     private static Logger log = Logger.getLogger(Fitting.class);
@@ -45,6 +47,7 @@
     protected double []     parameters;
     protected ArrayList<QW> removed;
     protected QWD []        referenced;
+    protected double        standardDeviation;
 
 
     public Fitting() {
@@ -95,6 +98,7 @@
         parameters = null;
         removed.clear();
         referenced = null;
+        standardDeviation = 0.0;
     }
 
     public boolean hasOutliers() {
@@ -129,6 +133,10 @@
         return parameters;
     }
 
+    public double getStandardDeviation() {
+        return standardDeviation;
+    }
+
     public boolean fit(double [] qs, double [] ws) {
 
         TDoubleArrayList xs = new TDoubleArrayList(qs.length);
@@ -205,6 +213,8 @@
             }
         }
 
+        StandardDeviation stdDev = new StandardDeviation();
+
         referenced = new QWD[xs.size()];
         for (int i = 0; i < referenced.length; ++i) {
             QWD qwd = qwdFactory.create(xs.getQuick(i), ys.getQuick(i));
@@ -216,9 +226,12 @@
                 referenced[i] = qwd;
                 double dw = (qwd.getW() - instance.value(qwd.getQ()))*100.0;
                 qwd.setDeltaW(dw);
+                stdDev.increment(dw);
             }
         }
 
+        standardDeviation = stdDev.getResult();
+
         chiSqr = lmo.getChiSquare();
 
         return true;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Tue Jun 19 14:01:47 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Tue Jun 19 15:28:40 2012 +0000
@@ -211,6 +211,7 @@
         int kmIndex             = results.columnIndex("km");
         int chiSqrIndex         = results.columnIndex("chi_sqr");
         int maxQIndex           = results.columnIndex("max_q");
+        int stdDevIndex         = results.columnIndex("std-dev");
         int [] parameterIndices = results.columnIndices(parameterNames);
 
         int numFailed = 0;
@@ -243,7 +244,8 @@
 
             results.set(row, kmIndex, km);
             results.set(row, chiSqrIndex, fitting.getChiSquare());
-            results.set(row, maxQIndex, fitting.getMaxQ());
+            results.set(row, stdDevIndex, fitting.getStandardDeviation());
+            results.set(row, maxQIndex,   fitting.getMaxQ());
             invalid |= results.set(
                 row, parameterIndices, fitting.getParameters());
         }
@@ -578,11 +580,12 @@
     }
 
     protected static String [] createColumnNames(String [] parameters) {
-        String [] result = new String[parameters.length + 3];
+        String [] result = new String[parameters.length + 4];
         result[0] = "km";
         result[1] = "chi_sqr";
         result[2] = "max_q";
-        System.arraycopy(parameters, 0, result, 3, parameters.length);
+        result[3] = "std-dev";
+        System.arraycopy(parameters, 0, result, 4, parameters.length);
         return result;
     }
 }

http://dive4elements.wald.intevation.org