CLsqFit Class Description


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

Plotting a Least Squares Fit

Usage

Construction

Object = new_lsqfit()

Object = CLsqFit:new()

Destruction

Object:delete()

Creation - Non-class Functions

This function is normally used to create a new CLsqFit object as an alternative to the class-based new method.

new_lsqfit

Creates a new instance of the CLsqFit class.

Construction and Destruction - Class Methods

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 sample data. The point is added at the next point index.

AddPtWt

Adds a point to the sample data with a point weight. The point is added at the next point index.

GetPtX

Returns the values of the independent variable for a point by the point's index.

SetPtX

Sets the values of the independent variables for a point by the point's index.

GetPtObs

Returns the observed value of a sample point by the point's index.

SetPtObs

Sets the observed value at an existing point by the point's index.

GetPtWt

Returns the weight of a point.

SetPtWt

Sets the weight of a point by the point's index.

GetPtStatus

Returns the status code of a sample point. This is a number 0, 1, or 2 for used, deleted, or rejected. It is useful when data rejection is enabled.

GetPtStatusStr

Returns the status string of a sample point as "use", "rej", or "del" (used, deleted, or rejected). It is useful 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


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