CLsqFit:GetNumPts


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

Syntax

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.

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 = CLsqFit:new()

-- 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

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

GetNumPtsUsed

GetNumPtsRejected

GetNumPtsDeleted

CLsqFit class