de.jstacs.algorithms.optimization
Class NumericalDifferentiableFunction
java.lang.Object
de.jstacs.algorithms.optimization.DifferentiableFunction
de.jstacs.algorithms.optimization.NumericalDifferentiableFunction
- All Implemented Interfaces:
- Function
public abstract class NumericalDifferentiableFunction
- extends DifferentiableFunction
This class is the framework for any function f: R^n -> R. The gradient is computed numerically. Each partial
differentiation is computed by the formula
\partial_k f(x) = \frac{f(x)-f(x+\varepsilon*e_k)}{\varepsilon}
- Author:
- Jens Keilwagen
Field Summary |
protected double |
eps
The constant used in the computation of the gradient. |
Method Summary |
double[] |
evaluateGradientOfFunction(double[] x)
Evaluates the gradient of function at a certain vector (in mathematical sense) x numerically. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
eps
protected double eps
- The constant used in the computation of the gradient. Sould be close to 0 but not exactly 0.
NumericalDifferentiableFunction
public NumericalDifferentiableFunction(double epsilon)
throws IllegalArgumentException
- Parameters:
epsilon
- the epsilon used for the numerical differentiation
- Throws:
IllegalArgumentException
- if epsilon = 0;
evaluateGradientOfFunction
public double[] evaluateGradientOfFunction(double[] x)
throws DimensionException,
EvaluationException
- Evaluates the gradient of function at a certain vector (in mathematical sense)
x
numerically.
- Specified by:
evaluateGradientOfFunction
in class DifferentiableFunction
- Parameters:
x
- the current vector
- Returns:
- the elvaluation of the gradient of a function; has dimension
getDimensionOfScope()
- Throws:
DimensionException
- if dim(x) != n, with f: R^n -> R
EvaluationException
- if there was a mistake in evaluating the gradient- See Also:
Function.getDimensionOfScope()