Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/fitting/InvLog.java @ 3177:585c0b49e696
Added inverses of the fitting functions.
flys-artifacts/trunk@4792 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 26 Jun 2012 06:33:37 +0000 |
parents | |
children | 9422b559b2d5 |
comparison
equal
deleted
inserted
replaced
3176:cbaa49896eca | 3177:585c0b49e696 |
---|---|
1 package de.intevation.flys.artifacts.math.fitting; | |
2 | |
3 public class InvLog | |
4 extends Function | |
5 { | |
6 public static final Derivative DERIVATIVE = | |
7 new Derivative("Q'(W) = exp(W/m)/m") { | |
8 | |
9 @Override | |
10 public de.intevation.flys.artifacts.math.Function | |
11 instantiate(double [] parameters) | |
12 { | |
13 final double _1m = 1d / parameters[0]; | |
14 | |
15 return new de.intevation.flys.artifacts.math.Function() { | |
16 @Override | |
17 public double value(double W) { | |
18 return Math.exp(W*_1m)*_1m; | |
19 } | |
20 }; | |
21 } | |
22 }; | |
23 | |
24 public static final Function INSTANCE = new InvLog(); | |
25 | |
26 public InvLog() { | |
27 super("inv-log", "Q(W) = e^(W/m) - b", new String [] { "m", "b" }); | |
28 } | |
29 | |
30 @Override | |
31 public double value(double w, double [] parameters) { | |
32 double m = parameters[0]; | |
33 double b = parameters[1]; | |
34 return Math.exp(w/m) - b; | |
35 } | |
36 | |
37 @Override | |
38 public double [] gradient(double w, double [] parameters) { | |
39 double m = parameters[0]; | |
40 double b = parameters[1]; | |
41 double ewm = Math.exp(w/m); | |
42 return new double [] { -w*ewm/(m*m), -1 }; | |
43 } | |
44 | |
45 @Override | |
46 public Derivative getDerivative() { | |
47 return DERIVATIVE; | |
48 } | |
49 | |
50 @Override | |
51 public Function getInverse() { | |
52 return Log.INSTANCE; | |
53 } | |
54 } | |
55 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | |
56 |