CLsqFit:Using the CLsqFit Class

CLsqFit Class


The CLsqFit class performs least squares analysis of sample data. This class uses the linear least squares method to fit up to 100 coefficients for 1 to 10 independent variables. Options include fitting single channel or RGB data, built-in or user-defined basis functions, iterative data rejection, point editing, and forcing coefficients to specified values.

Despite the power and versatility of this class, its user interface is remarkably simple. For example, the AddPt method adds data points to the sample; using various argument lists, the same method is used to specify 1 to 10 values of the independent variables as well as the observed value for either numeric or RGB data.

CLsqFit Class Topics

Using the CLsqFit Class

Basis Functions

Using Multiple Independent Variables

Working with RGB data

Forcing Coefficient Values

Rejecting Outliers from the Fit

Using CLsqFit with Image Pixels

Usage

Construction

Object = CLsqFit:new()

Destruction

Object:delete()

Properties

This class has no exposed properties.

Construction

new

Creates a new instance of the CLsqFit class.

delete

Deletes the instance of the CLsqFit object.

Operations

Configuring the Fit

SetNumCoefs

Sets the number of coefficients and, optionally, the number of independent variables, or "basis dimensions".

GetNumCoefs

Returns the number of coefficients in total or for the specified basis dimension.

SetBasisFunc

Specifies the basis function. The options are an n-dimensional polynomial (the default), an n-dimensional hyperplane or a user provided function.

GetBasisFunc

Returns the basis function that is selected.

GetBasisDim

Returns the number of independent variables, or "basis dimensions".

SetNumChannels

Sets the number of data channels to fit. The options are 1 (the default), 3, or 4.

GetNumChannels

Returns the number of channels being fit.

Computing the Fit

Fit

Computes the fit.

ResetPoints

Initializes the fit data by deleting all points that have been added.

DoRejection

Enables (the default) or disables iterative data rejection.

ForceCoef

Forces a coefficient to a specified value and does not estimate it in the fit.

UnforceCoef

Restores a forced coefficient to the pool of coefficients being fit.

IsCoefForced

Returns the state of a coefficient (estimated or forced).

ResetForcedCoefs

Resets all forced coefficients so they all will be estimated by the fit.

GetErrMsg

Returns an error message if the fit fails.

GetErrChan

Returns the channel number where the fit failed.

Working with Fit Results

GetCoef

Returns a coefficient value from the fit.

GetCoefErr

Returns the error in the coefficient value from the fit.

GetCovar

Returns a covariance from the fit covariance matrix.

GetSigmaFit

Returns the standard deviation of the fit.

Eval

Evaluates the predicted value of a specified point using the fit results.

GetResid

Returns the residual for a point used in the fit.

GetSampleMean

Returns the mean value for the specified basis dimension.

GetRangeX

Returns the min and max values of the independent variable(s).

GetRangeObs

Returns the min and max values of the observations.

GetNumPts

Returns the number of points added to the sample.

GetNumPtsUsed

Returns the number of points used in the fit.

GetNumPtsRejected

Returns the number of points rejected from the fit when data rejection is enabled.

GetNumPtsDeleted

Returns the number of points that were manually deleted.

GetPolyCoefIndex

Returns the index of a coefficient based on its dimensional index (used only for the default n-dimensional polynomial basis function).

Working with Sample Points

AddPt

Adds a point to the fit collection.

AddPtWt

Adds a point with a weight to the first collection.

GetPtX

Returns the value(s) of the independent variable(s) for an existing sample point.

SetPtX

Sets the value(s) of the independent variable for an existing sample point.

GetPtObs

Returns the observed value of an existing sample point.

SetPtObs

Sets the observed value of an existing sample point.

GetPtWt

Returns the weight of a sample point

SetPtWt

Sets the weight of a sample point.

GetPtStatus

Returns the status of asample point (used, deleted, or rejected) when data rejection is enabled.

GetX

Returns an table containing all the point X (basis) values for one of the basis dimensions.

GetObs

Returns a table containing all the point Y (observed) values.

GetWt

Rreturns a table containing all the point weights.

SetPtStatus

Sets the status of an existing data point to used, rejected, or deleted.

FindPt

Returns the index of a point based on a match to its values.

DeletePt

Manually deletes a point from the fit.

UndeletePt

Undeletes a point that was deleted from the fit.

Configuring Data Rejection

DoRejection

Enables (the default) or disables iterative data rejection.

SetRejDefault

Sets default values for data rejection parameters.

SetRejSigmaHigh

Sets the high sigma value used for Rejecting Outliers having residuals above the fit.

GetRejSigmaHigh

Returns the high sigma value used for Rejecting Outliers having residuals above the fit.

SetRejSigmaLow

Sets the low sigma value used for Rejecting Outliers having residuals below the fit.

GetRejSigmaLow

Returns the low sigma value used for Rejecting Outliers having residuals below the fit.

SetRejCycles

Sets the number of cycles used for Rejecting Outliers from the fit.

GetRejCycles

Returns the number of cycles used for Rejecting Outliers from the fit.

Related Topics

Class Overview