|
NAG[e02gac] NAG[nag_lone_fit] - -approximation by general linear function
|
|
Calling Sequence
e02gac(a, b, x, resid, rank, iter, 'm'=m, 'nplus2'=nplus2, 'toler'=toler, 'fail'=fail)
nag_lone_fit(. . .)
Parameters
|
a - Matrix(1.. , 1..nplus2, datatype=float[8], order=order);
|
|
|
Note: this array may be supplied in Fortran_order or C_order , as specified by order. All array parameters must use a consistent order.
|
|
Note: the dimension, dim, of the array a must be at least .
|
|
On exit: contains the last simplex tableau generated by the simplex method.
|
|
|
b - Vector(1..m, datatype=float[8]);
|
|
|
|
x - Vector(1..nplus2, datatype=float[8]);
|
|
|
|
resid - assignable;
|
|
|
Note: On exit the variable resid will have a value of type float.
|
|
On exit: the sum of the absolute values of the residuals for the solution vector .
|
|
|
rank - assignable;
|
|
|
Note: On exit the variable rank will have a value of type integer.
|
|
On exit: the computed rank of the matrix .
|
|
|
iter - assignable;
|
|
|
Note: On exit the variable iter will have a value of type integer.
|
|
On exit: the number of iterations taken by the simplex method.
|
|
|
'm'=m - integer; (optional)
|
|
|
On entry: the number of equations, (the number of rows of the matrix ).
|
|
Constraint: . .
|
|
|
'nplus2'=nplus2 - integer; (optional)
|
|
|
Constraint: . .
|
|
|
'toler'=toler - float; (optional)
|
|
|
On entry: a non-negative value. In general toler specifies a threshold below which numbers are regarded as zero. The recommended threshold value is where is the machine precision. The recommended value can be computed within the function by setting toler to zero. If premature termination occurs a larger value for toler may result in a valid solution.
|
|
Suggested value: . (default: )
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_lone_fit (e02gac) calculates an solution to an over-determined system of linear equations.
|
|
Description
|
|
Given a matrix with rows and columns and a vector with elements, the function calculates an solution to the over-determined system of equations
That is to say, it calculates a vector , with elements, which minimizes the norm (the sum of the absolute values) of the residuals
where the residuals are given by
Here is the element in row and column of , is the th element of and the th element of . The matrix need not be of full rank.
Typically in applications to data fitting, data consisting of points with co-ordinates are to be approximated in the norm by a linear combination of known functions ,
This is equivalent to fitting an solution to the over-determined system of equations
Thus if, for each value of and , the element of the matrix in the previous paragraph is set equal to the value of and is set equal to , the solution vector will contain the required values of the . Note that the independent variable above can, instead, be a vector of several independent variables (this includes the case where each is a function of a different variable, or set of variables).
The algorithm is a modification of the simplex method of linear programming applied to the primal formulation of the problem (see Barrodale and Roberts (1973) and Barrodale and Roberts (1974)). The modification allows several neighbouring simplex vertices to be passed through in a single iteration, providing a substantial improvement in efficiency.
|
|
Error Indicators and Warnings
|
|
"NE_ALLOC_FAIL"
Dynamic memory allocation failed.
"NE_BAD_PARAM"
On entry, argument had an illegal value.
"NE_INT"
On entry, . Constraint: .
"NE_INT_2"
On entry, , . Constraint: .
On entry, : , .
"NE_INTERNAL_ERROR"
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please consult NAG for assistance.
"NE_NON_UNIQUE"
An optimal solution has been obtained, but may not be unique.
"NE_TERMINATION_FAILURE"
Premature termination due to rounding errors. Try using larger value of toler: .
|
|
Accuracy
|
|
Experience suggests that the computational accuracy of the solution is comparable with the accuracy that could be obtained by applying Gaussian elimination with partial pivoting to the equations satisfied by this algorithm (i.e., those equations with zero residuals). The accuracy therefore varies with the conditioning of the problem, but has been found generally very satisfactory in practice.
|
|
|
Examples
|
|
>
|
m := 5:
nplus2 := 5:
toler := 0.0:
a := Matrix([[1, 1, 1, 0, 0], [1.22140275816017, 0.8187307530779818, 1, 0, 0], [1.49182469764127, 0.6703200460356393, 1, 0, 0], [1.822118800390509, 0.5488116360940264, 1, 0, 0], [2.225540928492468, 0.4493289641172216, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]], datatype=float[8]):
b := Vector([4.501, 4.36, 4.333, 4.418, 4.625], datatype=float[8]):
x := Vector(5, datatype=float[8]):
NAG:-e02gac(a, b, x, resid, rank, iter, 'm' = m, 'nplus2' = nplus2, 'toler' = toler):
|
|
|
See Also
|
|
Barrodale I and Roberts F D K (1973) An improved algorithm for discrete linear approximation SIAM J. Numer. Anal. 10 839–848
Barrodale I and Roberts F D K (1974) Solution of an overdetermined system of equations in the -norm Comm. ACM 17 (6) 319–320
e02 Chapter Introduction.
NAG Toolbox Overview.
NAG Web Site.
|
|