CLsqFit:FindPt CLsqFit:Fit

CLsqFit:Eval


The Eval method evaluates a coordinate point using the coefficients of the fit. The return value gives the predicted function value at the specified coordinates. Internally, this calculation subtracts the sample mean from each coordinate before evaluating the function using the coefficients.

Syntax

V = CLsqFit:Eval( x )

V = CLsqFit:Eval( tblX )

V1, V2, V3, V4 = CLsqFit:Eval( x )

V1, V2, V3, V4 = CLsqFit:Eval( tblX )

bullet.gif    x is the coordinate (independent variable) where the fit is to be evaluated.

bullet.gif    tblX is a 1-dimensional array containing n values for the n independent variables where the fit is to be evaluated. Use this form when the basis function takes more than 1 independent variable (i.e., the basis function uses more than 1 dimension).

bullet.gif    V,V1, V2, V3, and V4 are the estimated value of the function evaluated at the specified x or tblX coordinates. The number of values returned equals the number of channels.

Remarks

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.

Examples

The following example illustrates how to evaluate the fit to numeric (single channel) data.

L = new_lsqfit()

-- create a CLsqFit object

L:SetNumCoefs( 2 )

-- set 2 coefficients

L:AddPt( 3.5, 5.15 )

-- add a point for x = 3.5 and y = 5.15

-- add more points to the fit

 

L:Fit()

-- Fit the line

x = 14.5

-- choose x = 14.5 for evaluating the fit

V = L:Eval( x )

-- fetch the predicted value at x = 14.5

Printf( "V([%lg)= %lg\n", x, V )

-- 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 = new_lsqfit()

-- create a CLsqFit object

L:SetNumChannels( 3 )

-- specify 3 channels

L:SetNumCoefs( 2 )

-- set 2 coefficients

L:AddPt( 3.5, {6,24,254} )

-- add x = 3.5 and an RGB y = {6,24,254}

-- add more points to the fit

 

L:Fit()

-- Fit the line

x = 14.5

-- choose x = 14.5 for evaluating the fit

V1, V2, V3 = L:Eval( x )

-- fetch the predicted values at x = 14.5

Printf( "V([%lg)= %lg,%lg,%lg\n", x, V1, V2, V3 )

-- list the values

end

 

Related Topics

CLsqFit class

SetNumChannels

GetResid

 


Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.