diff options
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/util/ExponentialInterpolation.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/util/ExponentialInterpolation.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/util/ExponentialInterpolation.java b/src/uk/ac/ox/cs/pagoda/util/ExponentialInterpolation.java new file mode 100644 index 0000000..1d12169 --- /dev/null +++ b/src/uk/ac/ox/cs/pagoda/util/ExponentialInterpolation.java | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util; | ||
| 2 | |||
| 3 | /*** | ||
| 4 | * Get an exponential function given two points. | ||
| 5 | */ | ||
| 6 | public class ExponentialInterpolation { | ||
| 7 | |||
| 8 | private final double base; | ||
| 9 | private final double multiplicativeFactor; | ||
| 10 | |||
| 11 | /*** | ||
| 12 | * Compute the exponential function passing for the 2 given points. | ||
| 13 | * | ||
| 14 | * @param x1 | ||
| 15 | * @param y1 | ||
| 16 | * @param x2 | ||
| 17 | * @param y2 | ||
| 18 | */ | ||
| 19 | public ExponentialInterpolation(double x1, double y1, double x2, double y2) { | ||
| 20 | base = Math.pow(y2/y1, 1 / (x2 - x1)); | ||
| 21 | multiplicativeFactor = y1 / Math.pow(base, x1); | ||
| 22 | } | ||
| 23 | |||
| 24 | /*** | ||
| 25 | * Compute value of the function in x. | ||
| 26 | * | ||
| 27 | * @param x | ||
| 28 | * @return | ||
| 29 | */ | ||
| 30 | public double computeValue(double x) { | ||
| 31 | return multiplicativeFactor * Math.pow(base, x); | ||
| 32 | } | ||
| 33 | } | ||
