Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/LogLinearFittingOperation.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 |
comparison
equal
deleted
inserted
replaced
9645:eb1a29fe823f | 9646:0380717105ba |
---|---|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.model.fixings; | |
11 | |
12 import java.util.List; | |
13 | |
14 import org.dive4elements.river.artifacts.math.fitting.LogLinearAlternative; | |
15 import org.dive4elements.river.artifacts.model.fixings.fitting.LinearLogLinearizedFitting; | |
16 import org.dive4elements.river.artifacts.model.fixings.fitting.LinearLogLinearizedFitting.Result; | |
17 | |
18 /** | |
19 * @author Gernot Belger | |
20 */ | |
21 final class LogLinearFittingOperation extends AbstractFittingOperation implements IFittingOperation { | |
22 | |
23 public LogLinearFittingOperation(final LogLinearAlternative function) { | |
24 super(function); | |
25 } | |
26 | |
27 @Override | |
28 public Fitting execute(final List<FittingData> data) { | |
29 | |
30 final double[] obsDischarges = new double[data.size()]; | |
31 final double[] obsWaterlevels = new double[data.size()]; | |
32 | |
33 for (int i = 0; i < data.size(); i++) { | |
34 final FittingData fittingData = data.get(i); | |
35 | |
36 obsDischarges[i] = fittingData.q; | |
37 obsWaterlevels[i] = fittingData.w; | |
38 } | |
39 | |
40 final LinearLogLinearizedFitting fitting = new LinearLogLinearizedFitting(obsDischarges, obsWaterlevels); | |
41 | |
42 final Result result = fitting.optimize(); | |
43 final double a = result.getA(); | |
44 final double b = result.getB(); | |
45 final double m = result.getM(); | |
46 final double chiSquare = result.getChiSquare(); | |
47 | |
48 final double[] parameters = new double[] { a, m, b }; | |
49 | |
50 return createFitting(parameters, chiSquare, data); | |
51 } | |
52 } |