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( nIndex ) r = CLsqFit:GetResid( nIndex, nChannel ) r1, r2, r3, r4 = CLsqFit:GetResid( nIndex ) |
nIndex is the index of the point in the sample data.
nChannel is an optional parameter for the channel to search. If omitted, all channels are searched.
r, r1, r2, r3, and r4 are the residual values of the point in the sample data or in the channels of multi-channel (e.g., RGB) data. The number of values returned equals the number of channels.
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.
|
-- create a CLsqFit object |
|
-- set 2 coefficients |
|
-- add a point for x = 3.5 and y = 5.15 |
-- add more points to the 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 |
|
|
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 ):
|
-- create a CLsqFit object |
|
-- specify 3 channels |
|
-- set 2 coefficients |
|
-- add point for x = 3.5, y = "12, 242, 5.1" |
-- add more points to the fit |
|
|
-- Fit the line |
|
-- get the number of points to fit |
|
-- loop over all points |
|
-- fetch the residuals for the i-th point |
|
-- list the residual |
|
|
CLsqFit class, GetNumPts, GetNumPtsUsed, SetNumChannels, Eval
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.