Table Of Contents

General Linear Fitting (G Dataflow)

Last Modified: January 12, 2018

Finds the k-dimension linear curve values and the set of k-dimension linear fit coefficients, which describe the k-dimension linear curve that best represents the input data set using the Least Square, Least Absolute Residual, or Bisquare method.

connector_pane_image
datatype_icon

covariance selector

Whether the node computes the covariance matrix.

Name Value Description
do not compute Covariance Does not compute the covariance matrix.
compute Covariance Computes the covariance matrix.

Default: do not compute Covariance

datatype_icon

reset

A Boolean that specifies whether to reset the internal state of the node.

True Resets the internal state of the node.
False Does not reset the internal state of the node.

This input is available only if you wire a double-precision, floating-point number to y.

Default: False

datatype_icon

y

Observed data set.

The number of elements in y must equal the number of rows in H.

This input accepts a double-precision, floating-point number or a 1D array of double-precision, floating-point numbers.

datatype_icon

H

Matrix that represents the formula you use to fit the data set.

Example of Obtaining the Matrix H

Assume you have a set of observations (x, y). For example, you can obtain a set of observations through data acquisition. Also, assume you think the relationship between x and y is of the following form:

y = a 0 f 0 ( x ) + a 1 f 1 ( x ) + a 2 f 2 ( x ) + a 3 f 3 ( x ) + a 4 f 4 ( x )

where

  • f 0 ( x ) = 1.0
  • f 1 ( x ) = sin ( x 2 )
  • f 2 ( x ) = 3 cos ( x )
  • f 3 ( x ) = 1 x + 1
  • f 4 ( x ) = x 4

The following equation describes matrix H.

Hij = fj(xi)

where

  • Hij is element in the ith column and jth row of H
  • fj(xi) is the function value of the ith element in x

In this example, the number of columns in H equals the number of elements in x. the number of rows in H equals 5.

datatype_icon

weight

Weights for the observations.

weight must be the same size as y. The elements in weight cannot be 0. If an element in weight is less than 0, this node uses the absolute value of the element. If you do not wire an input to weight, this node sets all elements in weight to 1.

datatype_icon

tolerance

Value that determines when to stop the iterative adjustment of coefficients when you use the Least Absolute Residual or Bisquare methods.

If tolerance is less than or equal to 0, this node sets tolerance to 0.0001.

This input is available only if you wire a 1D array of double-precision, floating-point number to y.

How tolerance Affects the Outputs with Different Fitting Methods

For the Least Absolute Residual method, if the relative difference of the weighted mean error of the polynomial fit in two successive iterations is less than tolerance, this node returns resulting polynomial coefficients. For the Bisquare method, if any relative difference between polynomial coefficients in two successive iterations is less than tolerance, this node returns the resulting polynomial coefficients.

Default: 0.0001

datatype_icon

block size

Length of each set of data. The node performs computation for each set of data.

When you set block size to zero, the node calculates a cumulative solution for the input data from the time that you called or initialized the node. When block size is greater than zero, the node calculates the solution for only the newest set of input data.

This input is available only if you wire a double-precision, floating-point number to y.

Default: 100

datatype_icon

error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error

datatype_icon

algorithm

Algorithm this node uses to compute the best fit.

Use the SVD for Rank Deficient H algorithm only if H is rank deficient or does not have a full rank and if all other algorithms are unsuccessful.

Name Value Description
SVD 0 Uses the SVD algorithm.
Givens 1 Uses the Givens algorithm.
Givens2 2 Uses the Givens2 algorithm.
Householder 3 Uses the Householder algorithm.
LU Decomposition 4 Uses the LU Decomposition algorithm.
Cholesky 5 Uses the Cholesky algorithm.
SVD for Rank Deficient H 6 Uses the SVD for Rank Deficient H algorithm.

Default: SVD

datatype_icon

method

Fitting method.

Name Value Description
Least Square 0 Uses the least square method.
Least Absolute Residual 1 Uses the least absolute residual method.
Bisquare 2 Uses the bisquare method.

Default: Least Square

datatype_icon

best fit

Fitted data.

datatype_icon

coefficients

Set of coefficients that minimize chi squared.

datatype_icon

covariance

Matrix of covariance C with k-by-k elements. cjk is the covariance between ai and ak. cjj is the variance of aj. This node uses the following equation to compute the covariance matrix C:

C = ( H 0 T H 0 ) 1
datatype_icon

weight out

Actual weight of general linear fitting if the fitting method is Bisquare.

If the fitting method is Least Square or Least Absolute Residual, weight out returns the value you enter for weight.

This output is available only if you wire a 1D array of double-precision, floating-point numbers to y.

datatype_icon

error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.
datatype_icon

residue

Weighted mean error of the fitted model.

If method is Least Absolute Residual, residue is the weighted mean absolute error. Otherwise, residue is the weighted mean square error.

Algorithm for Calculating the General Linear Fit

The following linear data model demonstrates how to configure the input parameters and how to use this node to obtain the fitted values and the set of least square coefficients that best represents the relationship of observations (x, y):

y = f ( a , x ) = i = 0 n 1 a i f i ( x ) = a 0 f 0 ( x ) + a 1 f 1 ( x ) + ... + a n 1 f n 1 ( x )

where

  • a = {a0, a1, a2, ..., an - 1}
  • n is the total number of functions
  • fi(x) are modal functions

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported

Web Server: Not supported in VIs that run in a web application


Recently Viewed Topics