changeset 3165:6b13d7e7b403

FixA: Added more debug output. flys-artifacts/trunk@4778 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 25 Jun 2012 14:36:46 +0000
parents 6d0567a8387d
children 591be3486087
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/Log.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/LogLinear.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java
diffstat 4 files changed, 38 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Jun 25 13:15:35 2012 +0000
+++ b/flys-artifacts/ChangeLog	Mon Jun 25 14:36:46 2012 +0000
@@ -1,3 +1,13 @@
+2012-06-25	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java:
+	  Added debug output about the concrete coeffs found by the fitting.
+
+	* src/main/java/de/intevation/flys/artifacts/math/fitting/Log.java,
+	  src/main/java/de/intevation/flys/artifacts/math/fitting/LogLinear.java:
+	  Re-checked the partial deviations to the coeffs. Write the formulas
+	  more human readable.
+
 2012-06-25	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/jfree/ShapeRenderer.java: If a label collides
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/Log.java	Mon Jun 25 13:15:35 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/Log.java	Mon Jun 25 14:36:46 2012 +0000
@@ -33,9 +33,12 @@
 
     @Override
     public double [] gradient(double x, double [] parameters) {
+        double m = parameters[0];
+        double b = parameters[1];
+        double b_x = b + x;
         return new double [] {
-            Math.log(x + parameters[1]),
-            parameters[0]/(x + parameters[0])
+            Math.log(b_x),
+            m/b_x
         };
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/LogLinear.java	Mon Jun 25 13:15:35 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/LogLinear.java	Mon Jun 25 14:36:46 2012 +0000
@@ -37,11 +37,16 @@
 
     @Override
     public double [] gradient(double x, double [] parameters) {
-        double l = parameters[1]*x + parameters[2];
+        double a = parameters[0];
+        double m = parameters[1];
+        double b = parameters[2];
+
+        double lin = m*x + b;
+
         return new double [] {
-            Math.log(l),
-            parameters[0]*x/l,
-            parameters[0]/l
+            Math.log(lin),
+            a*x / lin,
+            a / lin
         };
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Mon Jun 25 13:15:35 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Mon Jun 25 14:36:46 2012 +0000
@@ -239,13 +239,17 @@
             }
 
             int row = results.newRow();
+            double [] values = fitting.getParameters();
 
             results.set(row, kmIndex, km);
             results.set(row, chiSqrIndex, fitting.getChiSquare());
             results.set(row, stdDevIndex, fitting.getStandardDeviation());
             results.set(row, maxQIndex,   fitting.getMaxQ());
-            invalid |= results.set(
-                row, parameterIndices, fitting.getParameters());
+            invalid |= results.set(row, parameterIndices, values);
+
+            if (debug) {
+                log.debug("km: "+km+" " + toString(parameterNames, values));
+            }
         }
 
         if (debug) {
@@ -273,6 +277,14 @@
         return new CalculationResult(fr, this);
     }
 
+    protected String toString(String [] parameterNames, double [] values) {
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < parameterNames.length; ++i) {
+            if (i > 0) sb.append(", ");
+            sb.append(parameterNames[i]).append(": ").append(values[i]);
+        }
+        return sb.toString();
+    }
 
     protected List<Column> getEventColumns(FixingsOverview overview) {
 

http://dive4elements.wald.intevation.org