Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/math/fitting/InvLogLinear.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/src/main/java/org/dive4elements/river/artifacts/math/fitting/InvLogLinear.java@bd047b71ab37 |
children | 4897a58c8746 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.artifacts.math.fitting; | |
2 | |
3 public class InvLogLinear | |
4 extends Function | |
5 { | |
6 public static final Derivative DERIVATIVE = | |
7 new Derivative("Q'(W) = e^(W/a)/(a*m)") { | |
8 | |
9 @Override | |
10 public org.dive4elements.river.artifacts.math.Function | |
11 instantiate(double [] parameters) | |
12 { | |
13 final double _1a = 1d/parameters[0]; | |
14 final double _1am = 1d/(parameters[0] * parameters[1]); | |
15 | |
16 return new org.dive4elements.river.artifacts.math.Function() { | |
17 @Override | |
18 public double value(double W) { | |
19 return Math.exp(W*_1a)*_1am; | |
20 } | |
21 }; | |
22 } | |
23 }; | |
24 public static final Function INSTANCE = new InvLogLinear(); | |
25 | |
26 public InvLogLinear() { | |
27 super( | |
28 "inv-log-linear", | |
29 "Q(W)=(e^(W/a)-b)/m", | |
30 new String [] { "a", "m", "b" }); | |
31 } | |
32 | |
33 @Override | |
34 public double value(double W, double [] parameters) { | |
35 double a = parameters[0]; | |
36 double m = parameters[1]; | |
37 double b = parameters[2]; | |
38 return (Math.exp(W/a) - b)/m; | |
39 } | |
40 | |
41 @Override | |
42 public double [] gradient(double W, double [] parameters) { | |
43 double a = parameters[0]; | |
44 double m = parameters[1]; | |
45 double b = parameters[2]; | |
46 double eWa = Math.exp(W/a); | |
47 return new double [] { | |
48 -(W*eWa)/(a*a*m) | |
49 -(eWa-b)/(m*m), | |
50 -1/m | |
51 }; | |
52 } | |
53 | |
54 @Override | |
55 public Derivative getDerivative() { | |
56 return DERIVATIVE; | |
57 } | |
58 | |
59 @Override | |
60 public Function getInverse() { | |
61 return LogLinear.INSTANCE; | |
62 } | |
63 } | |
64 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |