CLsqFit:GetNumPts
The GetNumPts method returns the total number of points added to the data sample.
nPts = CLsqFit:GetNumPts() |
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. Another case where the difference matters is in setting the upper index for listing results in a loop, since GetNumPtsUsed may lead to fewer points listed than in the original sample. In this case, a better practive would be to list all points using GetNumPts and, inside the loop, test or list the status of each point using GetStatus or GetPtStatusStr.
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 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 to the fit |
|
|
-- 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 |
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.