Polynomial

Finds the set of polynomial fit coefficients that best represents an input signal or input data set using a specific fitting method.

1378

Inputs/Outputs

datatype_icon

coefficient constraint

Constraints on the polynomial coefficients of a certain order.

Use this input if you know the exact values of certain polynomial coefficients.

This input is available only if you wire one of the following data types to signal or y:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
datatype_icon

order

Constrained order.

Default value: 0

datatype_icon

coefficient

Coefficient of the specific order.

Default value: 0

datatype_icon

polynomial order

Order of the polynomial.

polynomial order must be greater than or equal to 0. If polynomial order is less than zero, this node sets polynomial coefficients to an empty array and returns an error. In real applications, polynomial order is less than 10. If polynomial order is greater than 25, the node sets polynomial coefficients to zero and returns a warning.

Default value: 2

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 or signal.

Default value: False

datatype_icon

signal

Input signal.

This input accepts a waveform or a 1D array of waveforms.

This input changes to y when the data type is a double-precision, floating-point number or a 1D array of double-precision, floating-point numbers.

datatype_icon

y

Dependent values representing the y-values of the data set.

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

This input changes to signal when the data type is a waveform or a 1D array of waveforms.

datatype_icon

x

Independent values representing the x-values of the data set.

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

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

datatype_icon

weight

An array of weights for the data set.

This input is available only if you wire one of the following data types to signal or y:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
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 one of the following data types to signal or y.

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers

Default value: 0.0001

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.

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 signal or y.

Default value: 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

Default value: No error

datatype_icon

algorithm

Algorithm this node uses to compute the polynomial curve that best fits the input values.

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 value: SVD

datatype_icon

method

Method of fitting data to a polynomial curve.

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 value: Least Square

Algorithm for the Least Square Method

The least square method finds the polynomial coefficients of the polynomial model by minimizing the residue according to the following equation:

where

  • N is the length of y or the number of data values in a waveform
  • w i is the ith element of weight
  • f i is the ith element of best polynomial fit
  • y i is the ith element of y or the ith data value in a waveform

Algorithm for the Least Absolute Residual Method

The least absolute residual method finds the polynomial coefficients of the polynomial model by minimizing the residue according to the following equation:

where

  • N is the length of y or the number of data values in a waveform
  • w i is the ith element of weight
  • f i is the ith element of best polynomial fit
  • y i is the ith element of y or the ith data value in a waveform

Algorithm for the Bisquare Method

The bisquare method finds the polynomial coefficients using an iterative process, as shown in the following illustration.

1378

The node calculates residue according to the following equation:

where

  • N is the length of y or the number of data values in a waveform
  • w i is the ith element of weight
  • f i is the ith element of best polynomial fit
  • y i is the ith element of y or the ith data value in a waveform
datatype_icon

best polynomial fit

Polynomial curve that best fits the input signal.

This output can return the following data types:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
datatype_icon

polynomial coefficients

Coefficients of the fitted model in ascending order of power. The total number of elements in polynomial coefficients is m + 1, where m is polynomial order.

datatype_icon

error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

datatype_icon

residue

Weighted mean error of the fitted model.

This output can return a double-precision, floating-point number or a 1D array of double-precision, floating-point numbers.

Algorithm for Calculating residue When the Input Signal is a Double-Precision, Floating-Point Number

When the input signal is a double-precision, floating-point number, this node calculates residue according to the following equation:

where

  • N is the number of elements in the data set
  • f i is the ith element of best linear fit
  • y i is the y component of the ith input data point

Examples

The following illustration shows a general polynomial fit result using this node:

1378

Algorithm for Calculating best polynomial fit

This node fits data to a polynomial function of the general form described by the following equation:

f i = j = 0 m a j x i j f i = j = 0 m a j x i j

where

  • f is the output sequence best polynomial fit
  • x is the input sequence calculated from the dt component of the input signal
  • a is polynomial coefficients
  • m is polynomial order

This node finds the value of a that best fits the observations (X, Y). When the input signal is an array of double-precision, floating-point numbers, X is the x component of the input signal and Y is y component of the input signal. When the input signal is a waveform or an array of waveforms, X is the input sequence calculated from the start time of the waveform and Y is the data values in the waveform.

The following equation describes the polynomial curve resulting from the general polynomial fit algorithm:

y [ i ] = j = 0 m a j ( x [ i ] ) j y [ i ] = j = 0 m a j ( x [ i ] ) j