CLsqFit:GetSampleMean
The GetSampleMean method returns the mean value of points in the sample for the n-th independent variable.
nMean = CLsqFit:GetSampleMean() nMean = CLsqFit:GetSampleMean( nDimension ) |
nDimension specifies the basis dimension (index of the independent variable). If not specified, 1 is assumed for a 1-dimensional fit.
nMean is the sample mean for the specified nDimension or the only dimension.
The sample means may be useful to know, especially when the basis function fits about the mean rather than about the origin (see Basis Functions). A table containing the sample means is passed to a user-defined basis function declared in the script, but the function does not have to use them to fit about the mean. The built-in basis functions fit about the mean automatically. In all cases,. the sample means are calculated even if you do not use them. You should not use the sample means in your calculations; The basis function determines whether the fit is done about the mean or the origin, so Mira automatically handles the sample means when you call Eval or other methods.
The following script adds points, fits a line, and then lists the sample mean. If there were two independent variables, like fitting a surface to x and y, then you could query GetSampleMean(1) and GetSampleMean(2) to get the means in the x and y data.
|
-- create a CLsqFit object |
|
-- set 2 coefficients to fit a line |
|
-- add data points |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Fit the polynomial |
|
-- get the sample mean for the x data |
|
-- result: Mean x = 4.57143 |
CLsqFit class, SetBasisFunc, GetBasisDim
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.