CLsqFit:Eval
The Eval method evaluates a point using the coefficients of the fit. The return value gives the predicted value of the point based on the specified independent variables.
V = CLsqFit:Eval( x ) V = CLsqFit:Eval( tableX ) V1, V2, V3, V4 = CLsqFit:Eval( x ) V1, V2, V3, V4 = CLsqFit:Eval( tableX ) |
The Eval method returns the value of the function estimated at a specified coordinates or set of coordinates in a multi-dimensional fit. If the fit involves 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.
The following example illustrates how to evaluate the 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 |
|
-- choose x = 14.5 for evaluating the fit |
|
-- fetch the predicted value at x = 14.5 |
|
-- list the value |
end |
|
The next example is similar to the first example, except that the fit involved RGB data. Note that 3 values are returned, one for each of the data channels:
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 = "6,24,254" |
|
-- add more points |
L:Fit() |
-- Fit the line |
|
-- choose x = 14.5 for evaluating the fit |
|
-- fetch the predicted values at x = 14.5 |
|
-- list the values |
end |
|