diff artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/fitting/SqrtErrorFunction.java @ 9646:0380717105ba

Implemented alternative fitting strategy for Log-Linear function.
author Gernot Belger <g.belger@bjoernsen.de>
date Mon, 02 Dec 2019 17:56:15 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/fitting/SqrtErrorFunction.java	Mon Dec 02 17:56:15 2019 +0100
@@ -0,0 +1,36 @@
+/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+package org.dive4elements.river.artifacts.model.fixings.fitting;
+
+/**
+ * @author Gernot Belger
+ */
+final class SqrtErrorFunction {
+
+    private final SQRTFunction sqrtFunction;
+
+    private final TargetFunction targetFunction;
+
+    public SqrtErrorFunction(final double[] obsWaterlevels, final TargetFunction targetFunction) {
+
+        this.targetFunction = targetFunction;
+        this.sqrtFunction = new SQRTFunction(obsWaterlevels);
+    }
+
+    public double value(final double a, final double b, final double m) {
+        return calc_sqrt_trans(a, b, m);
+    }
+
+    private double calc_sqrt_trans(final double a, final double b, final double m) {
+
+        final double[] waterlevels = this.targetFunction.calc_stages(a, b, m);
+        return this.sqrtFunction.calc_sqrt(waterlevels);
+    }
+}
\ No newline at end of file

http://dive4elements.wald.intevation.org