CLsqFit:GetPtWt


The GetPtWt method returns the weight assigned to an existing sample point.

Syntax

nWt = CLsqFit:GetPtWt( nIndex )

nWt = CLsqFit:GetPtWt( nIndex, nChannel )

nWt1, nWt2, nWt3, nWt4 = CLsqFit:GetPtWt( nIndex )

bullet.gif    nIndex is the index of the point in the sample, beginning at index 1.

bullet.gif    nChannel is the optional channel to select for multi-channel data.

bullet.gif    nWt is the weight assigned to the point.

bullet.gif    nWt1, nWt2, nWt3, nWt4 are weights assigned to points that have multi-channel (e.g., RGB) values. The number of values returned equals the number of channels.

Remarks

The GetPtWt 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 involving GetResid or other method.

This method returns the weight value or values in a 1-dimensional array even if the fit uses only 1 independent variable, or "basis dimension". The values at different basis dimensions are accessed as elements 1, 2, and so on. The number of elements in the table equals the number of basis dimensions used in the fit. Since Mira supports up to 10 dimensions, the table may caontain 1 to 10 elements. The number of table elements may be obtained using the # operator, like #tbl, or by calling the GetBasisDim method.

Two forms are provided with a different number of return values. If the point uses single-channel data (i.e., typical numeric data) or you specify the channel, then a single weight is returned. If the point involves multi-channel data, up to 4 values will be returned. The number of values returned is determined by the SetNumChannels method. The status can be modified using SetPtWt.

Example

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 = new_lsqfit()

-- 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 to the fit

 

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)

if L:GetPtWt(n) > 5 then

-- if the point has weight > 5

  L:SetPtWt( n, 2.5 )

-- reduce the weight of the point to 2.5

end

 

L:Fit()

-- get a new fit result using different weights

Related Topics

CLsqFit class, GetWt, SetPtWt, AddPt, AddPtWt, FindPt


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