Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/math/fitting/LogLinear.java @ 5863:4897a58c8746
River artifacts: Added new copyright headers.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 28 Apr 2013 14:40:59 +0200 |
parents | 5aa05a7a34b7 |
children | af13ceeba52a |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3178
diff
changeset
|
9 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
|
10 |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 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
|
12 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
|
13 { |
3009
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
14 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
|
15 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
|
16 |
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
17 @Override |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3178
diff
changeset
|
18 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
|
19 instantiate(double [] parameters) |
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
20 { |
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
21 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
|
22 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
|
23 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
|
24 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3178
diff
changeset
|
25 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
|
26 @Override |
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
27 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
|
28 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
|
29 } |
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
30 }; |
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
31 } |
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
32 }; |
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
33 |
3178
59b14bc676ec
Fitting: Link the functions to there inverses via getInverse().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3177
diff
changeset
|
34 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
|
35 |
2569
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 LogLinear() { |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 super( |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 "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
|
39 "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
|
40 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
|
41 } |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 @Override |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 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
|
45 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
|
46 } |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 @Override |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 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
|
50 double a = parameters[0]; |
6b13d7e7b403
FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3009
diff
changeset
|
51 double m = parameters[1]; |
6b13d7e7b403
FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3009
diff
changeset
|
52 double b = parameters[2]; |
6b13d7e7b403
FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3009
diff
changeset
|
53 |
6b13d7e7b403
FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3009
diff
changeset
|
54 double lin = m*x + b; |
6b13d7e7b403
FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3009
diff
changeset
|
55 |
2569
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 return new double [] { |
3165
6b13d7e7b403
FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3009
diff
changeset
|
57 Math.log(lin), |
6b13d7e7b403
FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3009
diff
changeset
|
58 a*x / lin, |
6b13d7e7b403
FixA: Added more debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3009
diff
changeset
|
59 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
|
60 }; |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
3009
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
62 |
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
63 @Override |
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
64 public Derivative getDerivative() { |
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
65 return DERIVATIVE; |
4dda67a893da
FixA: Added the derivatives of all fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2569
diff
changeset
|
66 } |
3177
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3165
diff
changeset
|
67 |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3165
diff
changeset
|
68 @Override |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3165
diff
changeset
|
69 public Function getInverse() { |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3165
diff
changeset
|
70 return InvLogLinear.INSTANCE; |
585c0b49e696
Added inverses of the fitting functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3165
diff
changeset
|
71 } |
2569
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 } |
0dd58ab7e118
Added functions to be used for fitting in the "Fixierungsanalyse" and "Extremwertermittlung".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |