CLsqFit:AddPtWt
The AddPtWt method adds weighted data points to the sample used in the fit. The number of coordinate values (independent variables) must match the dimensions of the fit. For the observed value (dependent variable), this function can fit both numeric values and RGB data passed as a table. To add points with the default weight of 1.0, use the AddPt method.
CLsqFit:AddPtWt( x, val, nWt ) CLsqFit:AddPtWt( x, y, val, nWt ) CLsqFit:AddPtWt( tblX, val, nWt ) CLsqFit:AddPtWt( tblX, tblRGB, nWt ) |
x is the coordinate for dimension 1 of the point when fitting 1-dimension.
tblX is a 1-dimensional array containing n elements equal to the number of dimensions in the fit. Use this form when the basis function takes more than one independent variable.
val is the numeric value of the observation at the coordinate x or the coordinate vector tblX.
tblRgb is a table of RGB channel values when fitting RGB data.
y is the second dimension for fitting numeric data to 2-dimensional (x,y) data. It is just a special form that avoids using a table for (x,y) when fitting the built-in 2-dimensional polynomial.
nWt is the point weight.
The AddPtWt and AddPt methods provide the only way to add points to the sample that will be fit. The AddPtWt method adds points with a specified weight whereas AddPt adds points with a weight of 1.0 ("unit weight"). You can later change a point's weight using SetPtWt.
This method allows both numeric data and multi-channel RGB data for the value parameter. To use multi-channel data, call SetNumChannels and specify 3 or 4 channels, then add points using a able for RGB or RGBa data.
Once added to the sample, a point can be deleted or its weight can be changed. In addition, a deleted point may be undeleted. If you want to permanently delete all sample points, call the ResetPoints method. After using ResetPoints, new points can be added to the same CLsqFit object using AddPtWt or AddPt.
The following example adds points with weights 1.0 and 0.5. The only difference between AddPt and AddPtWt is that AddPtWt specifies the point weight, therefore, you can also use the examples given for AddPt.
|
-- create a CLsqFit object (defaults to polynomial) |
|
-- set 2 coefficients |
|
-- add a point for x = 3.5, y = 5.15, weight = 1 |
|
-- add a point with a weight of 1 |
|
-- add a point at (x,y) with a weight of 0.5 |
|
-- Fit the line |
Note that you can mix AddPt and AddPtWt, as the only difference between them is the default or specified weight value. Here is the same example but using both AddPt and AddPtWt:
|
-- create a CLsqFit object |
|
-- set 2 coefficients |
|
-- add a point for x = 3.5, y = 5.15, weight = 1 |
|
-- add a point with a weight of 1 |
|
-- add a point at (x,y) with a weight of 0.5 |
|
-- Fit the line |
Using Multiple Independent Variables
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.