CLsqFit:IsCoefForced


The IsCoefForced method determines if a specified coefficient has been forced to a value.

Syntax

bForced = CLsqFit:IsCoefForced( nIndex )

bForced = CLsqFit:IsCoefForced( nIndex, nChan )

bullet.gif    nIndex is the index of the coefficient in the set of coefficients of the fit. This is a 1-based number.

bullet.gif    nChan is an optional parameter that specifies the target channel when fitting multi-channel data

bullet.gif    bForced is a boolean true or false value that indicates whether a coefficient was forced..

Remarks

If you are doing a complex fitting procedure and do not remember which coefficients were forced, use this method to query the status of a particular coefficient. To fit all coefficients after some were forced, you can remove all forcing in one step using ResetForcedCoefs.

This method takes a single number for the index of the coefficient to be polled. If you define the basis function in a script, then nIndex is simply an index into your list of coefficients to be fit. Alternatively, when using one of the built-in basis functions the index of the target coefficient is as follows:

bullet.gif    n-dimensional polynomial: This method requires use of a helper method to find the coefficient index in the n-dimensional coefficient matrix. See GetPolyCoefIndex.

bullet.gif    Hyperplane: The target coefficient can be identified knowing that the first coefficient applies to a constant value,

Example

This example shows how to forcing a coefficient in a 2x2 coefficient polynomial fit. After computing the fit, the cross term between x and y at index 2,2 is removed from the fit by setting it to 0, leaving a fit to an inclined plane rather than a warped plane.

L = new_lsqfit()

-- create the least squares fitting object

 

L:SetNumCoefs( {2,2} )

-- fit a polynomial with 2 coefs each in 2 dimensions

 

L:AddPt( -3, 1, 2 )

-- add an (x,y) point

 

L:AddPt( 4, 5, 3 )

-- add more points...

 

L:AddPt( 10, 8, 6 )

 

 

L:AddPt( 13, 17, 4.5 )

 

 

L:AddPt( 15, 12, 4 )

 

 

n = GetPolyCoefIndex( { 2, 2, } )

-- find the 2,2 coef in the 2x2 polynomial fit matrix

 

L:ForceCoef( n, 0.0 )

-- remove the cross-term at the 2,2 position

 

L:Fit()

-- use 4 coefficients with the 2,2 coef set to 0.0

 

bForced = L:IsCoefForced( n )

-- check whether the coef at 2,2 has been forced

 

Printf( "[%d] forced= %d", n, bForced )

-- result: [4] forced= 1

 

Related Topics

CLsqFit class, ForceCoef, ResetForcedCoefs


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