John W. Campbell

Class, fields and methods:

Class DetailsAccessible Fields

Refinement Methods

Curve Fitting

- Package:
- Jdl.JdlLib;
- Class name:
- JdlLeastSquares
- Class definition:
- public class JdlLeastSquares
- Extends:
- Object
- Implements:
- none
- Actions:
- none

Methods:

Least squares refinement - leastSquaresMQLCalculate sigma values - leastSquaresSigmas

The function minimised is:

m-1 F(x) = Sigma [f(j)(x[0],x[1],...x[n-1])]**2 (m>=n) j=0The user must supply an initial approximation to the required solution and an object supporting the LeastSquaresRefineable interface which implements a method to calculate the values of the functions f(j), j=0,1,...m-1 for any values of the refineable parameters.

The refinement code has been directly derived from SLATEC public domain Fortran routines written by K.L. Hiebert (SNLA).

*Method Definition:*- public static int leastSquaresMQL (int m, int n, double[] x, double acc, double h, JdlLeastSquaresRefineable lfn, JdlDouble fmin, double[] fvecc)
*Parameters List:*- m
- The number of functions f(j) occuring in the sum of squares.
- n
- The number of variables x[0] ... x[n-1] to be refined. Estimated values must be given on input and refined values are returned.
- x
- An array containing the 'n' refineable parameters x[0] ... x[n-1]. Estimated values must be given on input and refined values are returned.
- acc
- Tolerance in the Function value such that failure to decrease by more than this amount in an iteration signals completness. (Or, more precisely, used as the values for FTOL and XTOL in call to the SLATEC library routine DNLS1).
- h
- The step size to be used in calculating the partial derivatives (EPSFCN parameter in call to the SLATEC library routine DNLS1).
- lfn
- The object with the method to calculate the values of the functions f(j), j=0,1,..,m-1.
- fmin
- Returns the minimum value sum of squares in fmin.value.
- fvecc
- An array, dimensioned to at least m, returning the m values of f(j), j=0,1,...m-1 calculated using the refined parameter values.

*Method Return:*-
Output flag:

= 0, OK

= -1, error in parameters

= 1, algorithm estimates that the relative error in the sum of squares is at most 'acc'

= 2, algorithm estimates that the relative error between 'x' and the solution is at most 'acc'

= 3, conditions for flag = 1 and flag = 2 both hold

= 4, 'fvecc' is orthogonal to the columns of the Jacobian to machine precision

= 5, number of calls to function method has reached 200*(n+1). = 6, 'acc' is too small. No further reduction in the sum of squares is possible

= 7, 'acc' is too small. No further improvement in the approximate solution 'x' is possible

*Method Definition:*- public static int leastSquaresSigmas(int m, int n, double[] x, JdlLeastSquaresRefineable lfn, double[] sigma, double[] fvecc)
*Parameters List:*- m
- The number of functions f(j) occuring in the sum of squares.
- n
- The number of variables x[0] ... x[n-1] refined.
- x
- An array containing the 'n' refined parameters x[0] ... x[n-1].
- lfn
- The object with the method to calculate the values of the functions f(j), j=0,1,..,m-1.
- sigma
- This array returns the 'n' sigma values for the 'n' refined parameters.
- fvecc
- An array, dimensioned to at least m, returning the m values of f(j), j=0,1,...m-1 calculated using the refined parameter values.

*Method Return:*-
Output flag:

= 0, OK

= 1, Error in the parameters

= 2, Singular matrix

Methods:

Fit a curve - fitCurveFit a curve - fitCurve

*Method Definition:*- public static JdlChebyshevPolynomial fitCurve(int n, JdlXY[] xy, int iord, JdlDouble fmin, JdlError err)
*Parameters List:*- n
- The number of points to be used in the curve fitting.
- JdlXY
- The array of points to which the curve is to be fitted. 'x' is taken as the independent variable and 'y' as the dependent variable.
- iord
- The order of the polynomial to be used in the curve fitting (<= n-1).
- fmin
- Returns the least squares residual (sum of squares).
- err
- An error object in which to set error return codes. If an error is
found 'err.err' will be set to true, an error message will be returned in
'err.msg1' and the flag 'err.flag' will be set as follows:

= 0, OK

= -1, Invalid parameters

= -2, Order too large for number of points

> 0, Flag as from the leastSquaresMQL(..) method

*Method Return:*- A JdlChebyshevPolynomial object containing the fitted curve parameters - null if an error was found (see 'err') (Note that the stored 'outlim' parameter will be set to 0.0 by this method).

*Method Definition:*- public static JdlChebyshevPolynomial fitCurve(int n, JdlXY[] xy, double[] wt, int iord, JdlDouble fmin, JdlError err)
*Parameters List:*- n
- The number of points to be used in the curve fitting.
- JdlXY
- The array of points to which the curve is to be fitted. 'x' is taken as the independent variable and 'y' as the dependent variable.
- wt
- Weights for the 'n' points to be fitted.
- iord
- The order of the polynomial to be used in the curve fitting (<= n-1).
- fmin
- Returns the least squares residual (sum of squares).
- err
- An error object in which to set error return codes. If an error is
found 'err.err' will be set to true, an error message will be returned in
'err.msg1' and the flag 'err.flag' will be set as follows:

= 0, OK

= -1, Invalid parameters

= -2, Order too large for number of points

> 0, Flag as from the leastSquaresMQL(..) method

Values of -1, -2, and 4 are treated as fatal errors.

*Method Return:*- A JdlChebyshevPolynomial object containing the fitted curve parameters - null if a fatal error was found (see 'err') (Note that the stored 'outlim' parameter will be set to 0.0 by this method).

⇑ Up 2 ⇑ Up 1 ⇑ Top of this