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 )

nCovar = CLsqFit:GetCovar( nIndex1, nIndex2, nChannel )

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

bullet.gif    nIndex1 and nIndex2 are the coefficient indices. Both are numbers between 1 and GetNumCoefs.

bullet.gif    nCovar is the returned value of the covariance.

bullet.gif    nChannel is an optional argument that specifies the channel for multi-channel (RGB) data.

bullet.gif    nC1, nC2, nC3, and nC4 are the covariance values returned for multi-channel data when no channel is specified.

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


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