de.grogra.math
Class Newton

java.lang.Object
  extended by de.grogra.math.Newton

public class Newton
extends java.lang.Object

This class contains some numeric algorithms based on the Newton algorithm.

Author:
Ole Kniemeyer

Constructor Summary
Newton()
           
 
Method Summary
static void findExtremum(ObjectToDouble<double[]> function, double[] x, double[] prec, int maxSteps, double[] eps, double relax)
          Finds a local extremum by looking for a root of an approximation of the derivative of function.
static void findRoot(ObjectToObject<double[],double[]> function, double[] x, double[] prec, int maxSteps, double[] eps, double relax)
          Finds a root of function.
static void fit(ObjectToDouble<double[][]> function, DataTable data, double[] params, double[] prec)
           
static void fit(ObjectToDouble<double[][]> function, DataTable data, double[] params, double[] prec, int maxSteps, double[] eps, double relax)
          Fits function to data.
static void fitParameters(ObjectToDouble<double[]> function, DataTable data, double[] params, double[] prec)
           
static void fitParameters(ObjectToDouble<double[]> function, DataTable data, double[] params, double[] prec, int maxSteps, double[] eps, double relax)
           
static DataTable toDataTable(Dataset set)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Newton

public Newton()
Method Detail

findExtremum

public static void findExtremum(ObjectToDouble<double[]> function,
                                double[] x,
                                double[] prec,
                                int maxSteps,
                                double[] eps,
                                double relax)
Finds a local extremum by looking for a root of an approximation of the derivative of function. The approximation is obtained by difference quotients, the delta being given by eps.

Parameters:
function - the function
x - the start value and (after method invocation completes normally) the final value
prec - the precision to achieve
maxSteps - maximal number of iterations
eps - the delta to approximate differential quotients
relax - relaxation factor for step
See Also:
findRoot(de.grogra.xl.lang.ObjectToObject, double[], double[], int, double[], double)

findRoot

public static void findRoot(ObjectToObject<double[],double[]> function,
                            double[] x,
                            double[] prec,
                            int maxSteps,
                            double[] eps,
                            double relax)
Finds a root of function. Starting at x, the derivative of function is approximated by difference quotients (using eps as delta) to compute a new x according to Newton's method, using relax as factor which reduces the x-movement computed by Newton's method. If the movement is less than prec in all dimensions, this method returns normally. Otherwise, after maxSteps an ArithmeticException is thrown.

All arrays have to be of the same length.

Parameters:
function - the function
x - the start value and (after method invocation completes normally) the final value
prec - the precision to achieve
maxSteps - maximal number of iterations
eps - the delta to approximate differential quotients
relax - relaxation factor for step

fit

public static void fit(ObjectToDouble<double[][]> function,
                       DataTable data,
                       double[] params,
                       double[] prec)

fit

public static void fit(ObjectToDouble<double[][]> function,
                       DataTable data,
                       double[] params,
                       double[] prec,
                       int maxSteps,
                       double[] eps,
                       double relax)
Fits function to data. function gets an array as input whose first component contains the x-vector and whose second component contains the parameter vector. data contains for each row a data set consisting of the x-vector and (as last entry) the function value.

Parameters:
function - the function
data - the data table
params - the start value for the parameter vector and (after method invocation completes normally) the final value
prec - the precision to achieve
maxSteps - maximal number of iterations
eps - the delta to approximate differential quotients
relax - relaxation factor for step
See Also:
findExtremum(de.grogra.xl.lang.ObjectToDouble, double[], double[], int, double[], double), findRoot(de.grogra.xl.lang.ObjectToObject, double[], double[], int, double[], double)

fitParameters

public static void fitParameters(ObjectToDouble<double[]> function,
                                 DataTable data,
                                 double[] params,
                                 double[] prec)

fitParameters

public static void fitParameters(ObjectToDouble<double[]> function,
                                 DataTable data,
                                 double[] params,
                                 double[] prec,
                                 int maxSteps,
                                 double[] eps,
                                 double relax)

toDataTable

public static DataTable toDataTable(Dataset set)