de.jstacs.algorithms.optimization
Class NumericalDifferentiableFunction

java.lang.Object
  extended by de.jstacs.algorithms.optimization.DifferentiableFunction
      extended by de.jstacs.algorithms.optimization.NumericalDifferentiableFunction
All Implemented Interfaces:
Function

public abstract class NumericalDifferentiableFunction
extends DifferentiableFunction

This class is the framework for any numerical differentiable function $f: \mathbb{R}^n \to \mathbb{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.
 
Constructor Summary
NumericalDifferentiableFunction(double epsilon)
          Sets the value for epsilon for this NumericalDifferentiableFunction.
 
Method Summary
 double[] evaluateGradientOfFunction(double[] x)
          Evaluates the gradient of a function at a certain vector (in mathematical sense) x numerically.
 
Methods inherited from class de.jstacs.algorithms.optimization.DifferentiableFunction
findOneDimensionalMin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jstacs.algorithms.optimization.Function
evaluateFunction, getDimensionOfScope
 

Field Detail

eps

protected double eps
The constant used in the computation of the gradient. Should be close to 0 but not exactly 0.

Constructor Detail

NumericalDifferentiableFunction

public NumericalDifferentiableFunction(double epsilon)
                                throws IllegalArgumentException
Sets the value for epsilon for this NumericalDifferentiableFunction.

Parameters:
epsilon - the epsilon used for the numerical differentiation
Throws:
IllegalArgumentException - if epsilon = 0
Method Detail

evaluateGradientOfFunction

public double[] evaluateGradientOfFunction(double[] x)
                                    throws DimensionException,
                                           EvaluationException
Evaluates the gradient of a function at a certain vector (in mathematical sense) x numerically.

Specified by:
evaluateGradientOfFunction in class DifferentiableFunction
Parameters:
x - the current vector
Returns:
the evaluation of the gradient of a function, has dimension Function.getDimensionOfScope()
Throws:
DimensionException - if dim(x) != n, with $f: \mathbb{R}^n \to \mathbb{R}$
EvaluationException - if there was something wrong during the evaluation of the gradient
See Also:
DifferentiableFunction.evaluateGradientOfFunction(double[])