CLsqFit:GetNumPts


The GetNumPts method returns the total number of points added to the data sample.

Syntax

nPts = CLsqFit:GetNumPts()

bullet.gif    nPts is the total number of points added to the data sample.

Remarks

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.

Example

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.

L = new_lsqfit()

-- create a CLsqFit object

L:SetNumCoefs( {2.2} )

-- set 2x2 coefficients to fit a warped plane

L:AddPt( {3, 5}, 5.15 )

-- add a point with x = 3, y = 5, z = 5.15

-- add more points to the fit

 

L:DeletePt( 2 )

-- delete the point at index 2

L:DoRejection( true )

-- enable bad data rejection

L:Fit()

-- Fit the polynomial

nU = L:GetNumPtsUsed()

-- number of points used

nT = L:GetNumPts()

-- total number of points added to the sample

Printf( " Used %d of %d total\n", nU, nT )

-- list the number used and total number

Related Topics

CLsqFit class, GetNumPtsUsed, GetNumPtsRejected, GetNumPtsDeleted, Data Rejection


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