lsqnn
|
Contents: Citation, Description, Arguments, Usage, Examples, Sub-Functions, Related Functions, Source Supported Under Version: >1.00
Citation Nonnegative Least Squares:
Description Nonnegative least squares fitting
Arguments and Return Values Arguments: A two-dimensional matrix, a column vector, and an optional third input specifying the format to return Return Value: A vector with the fitted coefficients, or a structure containing the fitted coefficients and other fit quantities
Usage Syntax: lsqnn(library_matrix, vector_to_be_fitted[, mode]) library_matrix - A two-dimensional matrix (dimensions [m, n, 1]) with the library of known samples (e.g. spectra from mineral library), and a column vector with the unknown sample (e.g. spectrum of some rock) to be fitted with the library. vector_to_be_fitted - A column vector (dimensions [1, n, 1]) with the sample to be fitted. The first two inputs must have the same y-dimension.
The fitted coefficients calculated by this function must be positive or zero. This is for applications such as spectral deconvolution where it does not make physical sense to have negative coefficients. (What does it mean to have a sample that is -5% quartz?) For cases where any of the coefficients are allowed to be negative, use lsq. For cases where some but not all of the coefficients are allowed to be negative, use lsqsn.
If $3=0, lsqnn returns a column vector containing the fitted coefficients. Otherwise, it returns a structure with the fields A (fitted coefficients), Yfit (fitted spectrum), and other fields quantifying the errors in the fitted spectrum.
Examples dv> lsqnn()
Nonnegative least squares fitting
lsqnn(X,y) returns A such that X*A best approximates y
by minimizing the sum of squares of the residuals,
subject to the constraint that all elements of A are >= 0.
That is, A for which sum((y_i - X_i*A_i)^2) is minimized.
The data input X should have m rows, n columns, and 1 plane.
The test input y should have m rows, 1 column, and 1 plane.
Optional third input controls output mode
If $3 is 1 (or omitted), will print summary and return structure
with errors and fitted spectrum, in addition to calculated
coefficients.
If $3 is 0, will only return structure with coefficients
This means that the format of the output depends on $3.
This function uses an algorithm outlined in Lawson & Hanson 1974
Note that this function is set to stop after 100 iterations and
return its best solution if no convergence is reached by then.
S.Marshall 10-31-2010
0
dv> X
73x923x1 array of float, bsq format [269,516 bytes]
dv> y
1x923x1 array of float, bsq format [3,692 bytes]
dv> A = lsqnn(X, y, 0)
1x73x1 array of double, bsq format [584 bytes]
dv> A = lsqnn(X, y, 1)
4 iterations; 1 significant (nonzero) end members
Errors in fitted spectrum:
Mean absolute error: 0.053749
RMS error: 0.081349
Maximum absolute error: 0.249029
struct, 6 elements
A: 1x73x1 array of double, bsq format [584 bytes]
Yfit: 1x923x1 array of double, bsq format [7,384 bytes]
MAE: 0.0537490896174796
RMSE: 0.0813486861080412
maxE: 0.249029457569122
np: 4x1x1 array of short, bsq format [8 bytes]
dv> A = lsqnn(X, y)
4 iterations; 1 significant (nonzero) end members
Errors in fitted spectrum:
Mean absolute error: 0.053749
RMS error: 0.081349
Maximum absolute error: 0.249029
struct, 6 elements
A: 1x73x1 array of double, bsq format [584 bytes]
Yfit: 1x923x1 array of double, bsq format [7,384 bytes]
MAE: 0.0537490896174796
RMSE: 0.0813486861080412
maxE: 0.249029457569122
np: 4x1x1 array of short, bsq format [8 bytes]
|
DavinciWiki Mini-Nav Bar Contents
Contact Developers
All other topics
Recent Library Changes Created On: 12-02-2010 |