CLsqFit:GetCoefErr CLsqFit:GetPolyCoefIndex

CLsqFit:GetCovar


The GetCovar method returns the covariance between fit coefficients. The covariance measures the degree of relationship between the calculated coefficients. A lower value indicates greater significance in the independence between coefficient values.

Syntax

nCovar = CLsqFit:GetCovar( nIndex1, nIndex2, nChan* )

nC1, nC2, nC3, nC4 = CLsqFit:GetCovar( nIndex1, nIndex2 )

Remarks

This function returns the covariance between coefficients at two indices, nIndex1 and nIndex2. If multi-channel data has been enabled, then values are returned for all channels unless you specifically specify a channel. The errors of the coefficients can be obtained using GetCoefErr and the coefficients themselves can be obtained using GetCoef.

If using the built-in n-dimensional polynomial basis function with n > 1, then the index of the coefficient must be determined by calculating it from the polynomial dimensions or by using GetPolyCoefIndex.

Example

The following script fits a 2x2 polynomial, then retrieves the covariance between coefficients at 1, 1 and at 2, 2.

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:Fit()

-- Fit the polynomial

n1 = L:GetPolyCoefIndex( 1, 1 )

-- fetch the index of the coefficient at 1, 1

n2 = L:GetPolyCoefIndex( 2, 2 )

-- fetch the index of the coefficient at 2, 2

v = L:GetCovar( n1, n2 )

-- fetch the covariance between 1,1 and 2,2

Printf( "Cov[%d][%d]= %lg\n", n1, n2, v )

-- list the covariance

Related Topics

CLsqFit class, GetCoef, GetCoefErr, SetNumCoefs, GetPolyCoefIndex