java.lang.Object
de.grogra.math.Newton
This class contains some numeric algorithms based on the Newton
algorithm.
- Author:
- Ole Kniemeyer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidfindExtremum(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 offunction.static voidfindRoot(ObjectToObject<double[], double[]> function, double[] x, double[] prec, int maxSteps, double[] eps, double relax) Finds a root offunction.static voidfit(ObjectToDouble<double[][]> function, DataTable data, double[] params, double[] prec) static voidfit(ObjectToDouble<double[][]> function, DataTable data, double[] params, double[] prec, int maxSteps, double[] eps, double relax) Fitsfunctiontodata.static voidfitParameters(ObjectToDouble<double[]> function, DataTable data, double[] params, double[] prec) static voidfitParameters(ObjectToDouble<double[]> function, DataTable data, double[] params, double[] prec, int maxSteps, double[] eps, double relax) static DataTabletoDataTable(Dataset set)
-
Constructor Details
-
Newton
public Newton()
-
-
Method Details
-
findRoot
public static void findRoot(ObjectToObject<double[], double[]> function, double[] x, double[] prec, int maxSteps, double[] eps, double relax) Finds a root offunction. Starting atx, the derivative offunctionis approximated by difference quotients (usingepsas delta) to compute a newxaccording to Newton's method, usingrelaxas factor which reduces thex-movement computed by Newton's method. If the movement is less thanprecin all dimensions, this method returns normally. Otherwise, aftermaxStepsanArithmeticExceptionis thrown.All arrays have to be of the same length.
- Parameters:
function- the functionx- the start value and (after method invocation completes normally) the final valueprec- the precision to achievemaxSteps- maximal number of iterationseps- the delta to approximate differential quotientsrelax- relaxation factor for step
-
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 offunction. The approximation is obtained by difference quotients, the delta being given byeps.- Parameters:
function- the functionx- the start value and (after method invocation completes normally) the final valueprec- the precision to achievemaxSteps- maximal number of iterationseps- the delta to approximate differential quotientsrelax- relaxation factor for step- See Also:
-
fit
public static void fit(ObjectToDouble<double[][]> function, DataTable data, double[] params, double[] prec, int maxSteps, double[] eps, double relax) Fitsfunctiontodata.functiongets an array as input whose first component contains thex-vector and whose second component contains the parameter vector.datacontains for each row a data set consisting of thex-vector and (as last entry) the function value.- Parameters:
function- the functiondata- the data tableparams- the start value for the parameter vector and (after method invocation completes normally) the final valueprec- the precision to achievemaxSteps- maximal number of iterationseps- the delta to approximate differential quotientsrelax- relaxation factor for step- See Also:
-
fit
public static void fit(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) -
fitParameters
public static void fitParameters(ObjectToDouble<double[]> function, DataTable data, double[] params, double[] prec) -
toDataTable
-