Lsq2topb: Difference between revisions
Jump to navigation
Jump to search
imported>Jeremy (Importing text file) |
imported>Jeremy (Importing text file) |
||
Line 10: | Line 10: | ||
>> w(ii) = 1./(0.5+tsq(ii)/tsqst); %de-weights pts significantly below line | >> w(ii) = 1./(0.5+tsq(ii)/tsqst); %de-weights pts significantly below line | ||
i.e. w(ii) is smaller for residuals far below/(above) the fit line. | i.e. w(ii) is smaller for residuals far below/(above) the fit line. | ||
INPUTS | ====INPUTS==== | ||
* x = independent variable Mx1 vector. | * '''x''' = independent variable Mx1 vector. | ||
* y = dependent variable, Mx1 vector. | * '''y''' = dependent variable, Mx1 vector. | ||
* order = order of polynomial [scalar] for polynomial function of input (x). If (order) is empty, (options.p) must contain a MxK matrix of basis vectors to fit in lieu of polynomials of (x). | * '''order''' = order of polynomial [scalar] for polynomial function of input (x). If (order) is empty, (options.p) must contain a MxK matrix of basis vectors to fit in lieu of polynomials of (x). | ||
* res = approximate fit residual [scalar]. | * '''res''' = approximate fit residual [scalar]. | ||
*OPTIONAL INPUTS: | *'''OPTIONAL''' INPUTS: | ||
* ''k '' = number of components {default = rank of X-block}, and | * '''''k''' '' = number of components {default = rank of X-block}, and | ||
OUTPUTS | ====OUTPUTS==== | ||
* yi = the fit to input (y). | * '''yi''' = the fit to input (y). | ||
* resnorm = squared 2-norm of the residual. | * '''resnorm''' = squared 2-norm of the residual. | ||
* residual = y - yi. | * '''residual''' = y - yi. | ||
===Options=== | ===Options=== | ||
* options = structure array with the following fields : | * '''options''' = structure array with the following fields : | ||
* p: [ ] If (options.p) is empty, input (order) must be >0. Otherwise, options.p is a MxK matrix of basis vectors. | * '''p''': [ ] If (options.p) is empty, input (order) must be >0. Otherwise, options.p is a MxK matrix of basis vectors. | ||
* smooth: [ ] if >0 this adds smoothing by adding a penalty to the magnitude of the 2nd derivative. (empty or <=0 means no smooth). | * '''smooth''': [ ] if >0 this adds smoothing by adding a penalty to the magnitude of the 2nd derivative. (empty or <=0 means no smooth). | ||
* display: [ 'off' | {'on'} ] governs level of display to command window. | * '''display''': [ 'off' | {'on'} ] governs level of display to command window. | ||
* trbflag: [{'top'} | 'bottom' | 'middle'] flag that tells algorithm to fit (yi) to the top, bottom, or middle of the data cloud. | * '''trbflag''': [{'top'} | 'bottom' | 'middle'] flag that tells algorithm to fit (yi) to the top, bottom, or middle of the data cloud. | ||
* tsqlim: [0.99] limit that govers whether a data point is outside the fit residual defined by input (res). | * '''tsqlim''': [0.99] limit that govers whether a data point is outside the fit residual defined by input (res). | ||
* stopcrit: [1e-4 1e-4 1000 360] stopping criteria, iteration is continued until one of the stopping criterion is met [(rel tol) (abs tol) (max \# iterations) (max time [seconds])]. | * '''stopcrit''': [1e-4 1e-4 1000 360] stopping criteria, iteration is continued until one of the stopping criterion is met [(rel tol) (abs tol) (max \# iterations) (max time [seconds])]. | ||
* initwt: [ ] empty or Mx1 vector of initial weights (0<=w<=1). | * '''initwt''': [ ] empty or Mx1 vector of initial weights (0<=w<=1). | ||
===See Also=== | ===See Also=== | ||
[[baseine]], [[baselinew]], [[fastnnls]] | [[baseine]], [[baselinew]], [[fastnnls]] |
Revision as of 20:56, 2 September 2008
Purpose
Fits a polynomial to the top/(bottom) of data.
Synopsis
- [yi,resnorm,residual,options] = lsq2topb(x,y,order,res,options)
Description
For order=1 and fitting to top of data cloud, LSQ2TOPB finds (yi) that minimizes sum( (W\*( y - yi )).\^2 ) where W is a diagonal weighting matrix given by: >> tsq = residual/res; % (res) is an input >> tsqst = ttestp(1-options.tsqlim,5000,2); % T-test limit from table >> ii = find(tsq<-tsqst); % finds residuals below the line >> w(ii) = 1./(0.5+tsq(ii)/tsqst); %de-weights pts significantly below line i.e. w(ii) is smaller for residuals far below/(above) the fit line.
INPUTS
- x = independent variable Mx1 vector.
- y = dependent variable, Mx1 vector.
- order = order of polynomial [scalar] for polynomial function of input (x). If (order) is empty, (options.p) must contain a MxK matrix of basis vectors to fit in lieu of polynomials of (x).
- res = approximate fit residual [scalar].
- OPTIONAL INPUTS:
- k = number of components {default = rank of X-block}, and
OUTPUTS
- yi = the fit to input (y).
- resnorm = squared 2-norm of the residual.
- residual = y - yi.
Options
- options = structure array with the following fields :
- p: [ ] If (options.p) is empty, input (order) must be >0. Otherwise, options.p is a MxK matrix of basis vectors.
- smooth: [ ] if >0 this adds smoothing by adding a penalty to the magnitude of the 2nd derivative. (empty or <=0 means no smooth).
- display: [ 'off' | {'on'} ] governs level of display to command window.
- trbflag: [{'top'} | 'bottom' | 'middle'] flag that tells algorithm to fit (yi) to the top, bottom, or middle of the data cloud.
- tsqlim: [0.99] limit that govers whether a data point is outside the fit residual defined by input (res).
- stopcrit: [1e-4 1e-4 1000 360] stopping criteria, iteration is continued until one of the stopping criterion is met [(rel tol) (abs tol) (max \# iterations) (max time [seconds])].
- initwt: [ ] empty or Mx1 vector of initial weights (0<=w<=1).