CLsqFit:GetBasisFunc CLsqFit:GetCoef

CLsqFit:GetBasisDim


The GetBasisDim method returns the number of dimensions or independent variables. This value was set using the SetNumCoefs method.

Syntax

nDim = CLsqFit:GetBasisDim()

bullet.gif    nDim is a number between 1 and 10.

Remarks

This function returns the number of independent variables used in the fit. This equals the dimension of the basis. The sample points must be added with data for the corresponding number of dimensions as shown in AddPt and AddPtWt.

Example

The following script retrieves the number of dimensions used by the basis function being fit.

L = new_lsqfit()

-- create a CLsqFit object

 

-- no function declared, n-dimensional polynomial (1) used

L:SetNumCoefs( {2,2} )

-- Declare a 2x2 coefficient fit

nDim = L:GetBasisDim()

-- fetch the number of basis dimensions

Printf( "Dim = %d\n", nDim )

-- result: Dim = 2

The next example defines a basis function in the script and registers it, The basis function fits 2 coefficients to one independent variable (i.e., 1 dimension). The script then fetches the basis function properties.

function MyFunc( n, c )

-- declare a basis function

  b = {}

 

  b[1] = 1

 

  b[2] = c[1]

 

  return b

 

end

-- end of basis function

L = new_lsqfit()

-- create a CLsqFit object

L:SetBasisFunc( "MyFunc" )

-- register the basis function

L:SetNumCoefs( 2 )

-- fit 2 coefficients in 1 dimension

s = L:GetBasisFunc()

 

nDim = L:GetBasisDim()

-- fetch the number of basis dimensions

Printf( "Dim '%s'= %d\n", s, nDim )

-- result: Dim 'MyFunc' = 1

Related Topics

CLsqFit class

SetNumCoefs

SetBasisFunc

GetBasisFunc

 


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