annotate flys-artifacts/src/main/java/org/dive4elements/river/artifacts/math/fitting/LogLinear.java @ 5831:bd047b71ab37

Repaired internal references
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:06:39 +0200
parents flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/LogLinear.java@59b14bc676ec
children
rev   line source
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3178
diff changeset
1 package org.dive4elements.river.artifacts.math.fitting;
2569
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 public class LogLinear
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 extends Function
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 {
3009
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
6 public static final Derivative DERIVATIVE =
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
7 new Derivative("W'(Q) = a*m/(m*Q + b)") {
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
8
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
9 @Override
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3178
diff changeset
10 public org.dive4elements.river.artifacts.math.Function
3009
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
11 instantiate(double [] parameters)
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
12 {
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
13 final double a = parameters[0];
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
14 final double m = parameters[1];
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
15 final double b = parameters[2];
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
16
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3178
diff changeset
17 return new org.dive4elements.river.artifacts.math.Function() {
3009
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
18 @Override
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
19 public double value(double Q) {
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
20 return a*m/(m*Q + b);
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
21 }
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
22 };
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
23 }
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
24 };
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
25
3178
59b14bc676ec Fitting: Link the functions to there inverses via getInverse().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3177
diff changeset
26 public static final Function INSTANCE = new LogLinear();
59b14bc676ec Fitting: Link the functions to there inverses via getInverse().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3177
diff changeset
27
2569
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 public LogLinear() {
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 super(
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 "log-linear",
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 "W(Q) = a*ln(m*Q + b)",
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 new String [] { "a", "m", "b" });
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 }
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 @Override
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 public double value(double x, double [] parameters) {
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 return parameters[0]*Math.log(parameters[1]*x + parameters[2]);
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 }
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 @Override
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 public double [] gradient(double x, double [] parameters) {
3165
6b13d7e7b403 FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3009
diff changeset
42 double a = parameters[0];
6b13d7e7b403 FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3009
diff changeset
43 double m = parameters[1];
6b13d7e7b403 FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3009
diff changeset
44 double b = parameters[2];
6b13d7e7b403 FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3009
diff changeset
45
6b13d7e7b403 FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3009
diff changeset
46 double lin = m*x + b;
6b13d7e7b403 FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3009
diff changeset
47
2569
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 return new double [] {
3165
6b13d7e7b403 FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3009
diff changeset
49 Math.log(lin),
6b13d7e7b403 FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3009
diff changeset
50 a*x / lin,
6b13d7e7b403 FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3009
diff changeset
51 a / lin
2569
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 };
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 }
3009
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
54
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
55 @Override
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
56 public Derivative getDerivative() {
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
57 return DERIVATIVE;
4dda67a893da FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2569
diff changeset
58 }
3177
585c0b49e696 Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3165
diff changeset
59
585c0b49e696 Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3165
diff changeset
60 @Override
585c0b49e696 Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3165
diff changeset
61 public Function getInverse() {
585c0b49e696 Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3165
diff changeset
62 return InvLogLinear.INSTANCE;
585c0b49e696 Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3165
diff changeset
63 }
2569
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 }
0dd58ab7e118 Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org