jebl.math
Class NumericalDerivative

java.lang.Object
  extended by jebl.math.NumericalDerivative

public class NumericalDerivative
extends Object

approximates numerically the first and second derivatives of a function of a single variable and approximates gradient and diagonal of Hessian for multivariate functions

Author:
Korbinian Strimmer

Constructor Summary
NumericalDerivative()
           
 
Method Summary
static double[] diagonalHessian(MultivariateFunction f, double[] x)
          determine diagonal of Hessian
static double firstDerivative(UnivariateFunction f, double x)
          determine first derivative
static double[] gradient(MultivariateFunction f, double[] x)
          determine gradient
static void gradient(MultivariateFunction f, double[] x, double[] grad)
          determine gradient
static double secondDerivative(UnivariateFunction f, double x)
          determine second derivative
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumericalDerivative

public NumericalDerivative()
Method Detail

firstDerivative

public static double firstDerivative(UnivariateFunction f,
                                     double x)
determine first derivative

Parameters:
f - univariate function
x - argument
Returns:
first derivate at x

secondDerivative

public static double secondDerivative(UnivariateFunction f,
                                      double x)
determine second derivative

Parameters:
f - univariate function
x - argument
Returns:
second derivate at x

gradient

public static double[] gradient(MultivariateFunction f,
                                double[] x)
determine gradient

Parameters:
f - multivariate function
x - argument vector
Returns:
gradient at x

gradient

public static void gradient(MultivariateFunction f,
                            double[] x,
                            double[] grad)
determine gradient

Parameters:
f - multivariate function
x - argument vector
grad - vector for gradient

diagonalHessian

public static double[] diagonalHessian(MultivariateFunction f,
                                       double[] x)
determine diagonal of Hessian

Parameters:
f - multivariate function
x - argument vector
Returns:
vector with diagonal entries of Hessian