CLsqFit:GetRangeX


The GetRangeX method returns the minimum and maximum values of the independent variable in the sample.

Syntax

nMinX,nMaxX = CLsqFit:GetRangeX()

nMinX,nMaxX = CLsqFit:GetRangeX( nDimension )

where

    nDimension is an optional parameter that specifies the basis dimension (index of the independent variable) when the fit involves more than 1 basis dimension.

    nMinX, nMaxX are the minimum and maximum values, respectively.

  

This method returns the limiting values in the sample data for the specified dimension. If the data have only 1 dimension, such as "x", you do not need to specify the dimension.

Example

The following example returns the minimum and maximum x values in the data for fitting 1 independent variable, x:

L = CLsqFit:new()

-- create a CLsqFit object

L:SetNumCoefs( 2 )

-- set 2 coefficients

L:AddPt( -4.5, 2 )

 

L:AddPt( 5.2, 20 )

 

L:AddPt( 10.1, 35.5 )

 

L:AddPt( 13, 50 )

 

L:AddPt( 18.7, 65 )

 

L:AddPt( -3, 7 )

 

L:AddPt( 4, 25 )

 

L:AddPt( 9.7, 40 )

 

L:AddPt( 11, 55 )

 

L:AddPt( 14.5, 70 )

 

L:Fit()

-- Fit the line

x1, x2 = L:GetRangeX()

-- find the minimum and maximum x values

Printf("%lg,%lg\n", x1, x2 )

-- Result: -4.5, 18.7

Related Topics

GetRangeObs

CLsqFit class