CLsqFit:GetNumPts
The GetNumPts method returns the total number of points added to the data sample.
nPts = CLsqFit:GetNumPts() where |
nPts is the total number of points added to the data sample.
This method returns the total number of points added to the data sample using AddPt or AddPtWt. This number is channel independent, However, since the data channels of multi-channel data are treated separately by the fit, the other 3 point counters (number deleted, rejected, and used) are all channel dependent. For any channel number n, the following relation holds:
GetNumPts() = GetNumPtsUsed( n ) + GetNumPtsDeleted( n ) + GetNumPtsRejected( n ).
Be careful about the difference between GetNumPtsUsed and GetNumPts. The number returned by GetNumPts should be used in instances where you want to consider all points, such as listing a table of residuals for all points. If some points were removed from the fit, then the number of points used will be smaller than the number of points added to the sample, and setting the number of points used as a loop limit would result in looping over less than the total number of points.
The following script fits a 2x2 polynomial with data rejection enabled, then retrieves the total number of points added to the data sample and the number of points actually used in the fit.
|
-- create a CLsqFit object |
|
-- set 2x2 coefficients to fit a warped plane |
|
-- add a point with x = 3, y = 5, z = 5.15 |
|
-- add more points |
|
-- delete the point at index 2 |
|
-- enable bad data rejection |
|
-- Fit the polynomial |
|
-- number of points used |
|
-- total number of points added to the sample |
|
-- list the number used and total number |
Rejecting Outliers from the Fit