CLsqFit:GetPtObs CLsqFit:GetPtWt

CLsqFit:SetPtWt


The SetPtWt method alters the weight assigned to an existing sample point. The point must have been previously added to the sample using AddPt or AddPtWt.

Syntax

CLsqFit:SetPtWt( nIndex, nWt, nChannel* )

Remarks

The SetPtWt method uses the index of the target point. The index must either be known from the order that points were added to the sample, or determined by matching the target point's values using FindPt or a more complicated procedure such as using GetResid to identify the indices of points having high residuals from the fit. You also may fetch the weight currently assigned to a point using GetPtWt.

Examples

The following example illustrates how to change the weight of an existing point. In this case, the target point's index is found by matching its values:

L = CLsqFit:new()

-- create a CLsqFit object

L:SetNumCoefs( 2 )

-- set 2 coefficients to fit a line

L:AddPt( 3.5, 5.15 )

-- add a point for x = 3.5, y = 5.15, weight = 1

 

-- add more points

L:Fit()

-- Fit the line

 

-- do something with the fit results

n = L:FindPt( 3.5, 5.15 )

-- find the point (if we don't know it has index 1)

L:SetPtWt( n, 10 )

-- set the weight of point 1 to 10.0

L:Fit()

-- get a new fit result using different weights

Related Topics

CLsqFit class, GetPtWt, AddPt, FindPt, GetResid