java.lang.Object
de.grogra.math.Newton
This class contains some numeric algorithms based on the Newton
algorithm.
- Author:
- Ole Kniemeyer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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
.static void
findRoot
(ObjectToObject<double[], double[]> function, double[] x, double[] prec, int maxSteps, double[] eps, double relax) Finds a root offunction
.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) Fitsfunction
todata
.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)
-
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 offunction
is approximated by difference quotients (usingeps
as delta) to compute a newx
according to Newton's method, usingrelax
as factor which reduces thex
-movement computed by Newton's method. If the movement is less thanprec
in all dimensions, this method returns normally. Otherwise, aftermaxSteps
anArithmeticException
is 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) Fitsfunction
todata
.function
gets an array as input whose first component contains thex
-vector and whose second component contains the parameter vector.data
contains 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
-