CLsqFit:GetResid
The GetResid method returns the residual of a sample point defined as observed value minus the value predicted from the fit. use this method to assess the quality of data points and their effect on the resulting fit.
r = CLsqFit:GetResid( n, nChan* ) r = CLsqFit:GetResid( n, nChan* ) r1, r2, r3, r4 = CLsqFit:GetResid( n ) r1, r2, r3, r4 = CLsqFit:GetResid( n ) |
The GetResid method returns the residual value for the point at an index in the sample data. If the fit uses more than 1 channel, then the two forms are used to retrieve either a single value or the number of values specified by the SetNumChannels method.
This function is equivalent to computing the value of fit for a point using its basis coordinates and then subtracting that from its actual value in the data sample.
The following example illustrates how to retrieve the residuals of all data points in a fit to numeric (single channel) data.
L = CLsqFit:new() |
-- create a CLsqFit object |
L:SetNumCoefs( 2 ) |
-- set 2 coefficients |
|
-- add a point for x = 3.5 and y = 5.15 |
|
-- add more points |
L:Fit() |
-- Fit the line |
|
-- get the number of points added to the fit |
|
-- loop over all points |
|
-- fetch the residual for the i-th point |
|
-- list the residual |
end |
|
The next example is similar to the first example, except that the fit involved RGB data. Note that 3 values are returned for the residuals of the i-th point because the fit used SetNumChannels( 3 ):
L = CLsqFit:new() |
-- create a CLsqFit object |
L:SetNumChannels( 3 ) |
-- specify 3 channels |
L:SetNumCoefs( 2 ) |
-- set 2 coefficients |
|
-- add a point for x = 3.5 and y = "12, 242, 5.1" |
|
-- add more points |
L:Fit() |
-- Fit the line |
|
-- get the number of points added to the fit |
|
-- loop over all points |
|
-- fetch the residuals for the i-th point |
|
-- list the residual |
end |
|
CLsqFit class, GetNumPts, GetNumPtsUsed, SetNumChannels, Eval