naginterfaces.library.fit.glin_l1sol¶
- naginterfaces.library.fit.glin_l1sol(a, b, toler=0.0)[source]¶
glin_l1sol
calculates an solution to an overdetermined system of linear equations.For full information please refer to the NAG Library document for e02ga
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/e02/e02gaf.html
- Parameters
- afloat, array-like, shape
must contain , the element in the th row and th column of the matrix , for , for . The remaining elements need not be set.
- bfloat, array-like, shape
must contain , the th element of the vector , for .
- tolerfloat, optional
A non-negative value. In general 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 to zero. If premature termination occurs a larger value for may result in a valid solution.
- Returns
- afloat, ndarray, shape
Contains the last simplex tableau generated by the simplex method.
- bfloat, ndarray, shape
The th residual corresponding to the solution vector , for .
- xfloat, ndarray, shape
contains the th element of the solution vector , for . The elements and are unused.
- residfloat
The sum of the absolute values of the residuals for the solution vector .
- irankint
The computed rank of the matrix .
- iteraint
The number of iterations taken by the simplex method.
- Raises
- NagValueError
- (errno )
Premature termination due to rounding errors. Try using larger value of : .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, .
Constraint: .
- Warns
- NagAlgorithmicWarning
- (errno )
An optimal solution has been obtained, but may not be unique.
- (errno )
More than iterations were performed.
glin_l1sol
has terminated without calculating a solution. The output data from the function is as computed on the last good iteration. Consider increasing the value of . Alternatively, may be ill conditioned—try scaling its columns.
- Notes
Given a matrix with rows and columns and a vector with elements, the function calculates an solution to the overdetermined 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 coordinates are to be approximated in the norm by a linear combination of known functions ,
This is equivalent to fitting an solution to the overdetermined 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.
- References
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