Table Of Contents

Curve Fitting (Linear) (G Dataflow)

Version:
    Last Modified: January 9, 2017

    Finds the line that best represents an input signal or input data set using a specific fitting method.

    connector_pane_image
    datatype_icon

    signal

    The input signal.

    This input accepts the following data types:

    • Waveform
    • Array of waveforms

    This input changes to y when the data type is an array of double-precision, floating-point numbers.

    datatype_icon

    y

    An array of dependent values representing the y-values of the data set.

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

    datatype_icon

    x

    An array of independent values representing the x-values of the data set.

    This input is available only if you wire an array of double-precision floating-point numbers to y or signal.

    datatype_icon

    weight

    An array of weights for the data set.

    datatype_icon

    tolerance

    Value that determines when to stop the iterative adjustment of the slope and intercept 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.

    How tolerance Affects the Outputs with Different Fitting Methods

    For the Least Absolute Residual method, if the relative difference between residue in two successive iterations is less than tolerance, this node returns the resulting residue. For the Bisquare method, if any relative difference between slope and intercept in two successive iterations is less than tolerance, this node returns the resulting slope and intercept.

    Default: 0.0001

    datatype_icon

    error in

    Error conditions that occur before this node runs. The node responds to this input according to standard error behavior.

    Default: No error

    datatype_icon

    parameter bounds

    Upper and lower constraints for the slope and intercept of the calculated best linear fit.

    datatype_icon

    slope min

    Lower bound for the slope.

    Default: -Infinity

    datatype_icon

    slope max

    Upper bound for the slope.

    Default: Infinity

    datatype_icon

    intercept min

    Lower bound for the intercept.

    Default: -Infinity

    datatype_icon

    intercept max

    Upper bound for the intercept.

    Default: Infinity

    datatype_icon

    method

    Method of fitting data to a line.

    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.

    Algorithm for the Least Square Method

    The least square method of fitting finds the slope and intercept of the linear model by minimizing residue according to the following equation:

    1 N i = 0 N 1 w i ( f i y i ) 2

    where

    • N is the length of y or the number of data values in a waveform
    • wi is the ith element of weight
    • fi is the ith element of best linear fit
    • yi 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 slope and intercept of the linear model by minimizing residue according to the following equation:

    1 N i = 0 N 1 w i | f i y i |

    where

    • N is the length of y or the number of data values in a waveform
    • wi is the ith element of weight
    • fi is the ith element of best linear fit
    • yi is the ith element of y or the ith data value in a waveform

    Algorithm for the Bisquare Method

    The bisquare method of fitting finds the slope and intercept using an iterative process, as shown in the following illustration.

    The node calculates residue according to the following equation:

    1 N i = 0 N 1 w i ( f i y i ) 2

    where

    • N is the length of y or the number of data values in a waveform
    • wi is the ith element of weight
    • fi is the ith element of best linear fit
    • yi is the ith element of y or the ith data value in a waveform.

    Default: Least Square

    datatype_icon

    best linear fit

    A waveform or array representing the line that best fits the input signal.

    datatype_icon

    slope

    Slope of the calculated best linear fit.

    datatype_icon

    intercept

    Intercept of the calculated best linear fit.

    datatype_icon

    error out

    Error information. The node produces this output according to standard error behavior.

    datatype_icon

    residue

    Weighted mean error of the fitted model.

    Algorithm for Calculating best linear fit

    This node uses the general least squares method to fit the data points in an input signal to a straight line of the general form described by the following equation:

    f = a x + b

    where x is an input sequence, a is the slope of best linear fit, and b is the intercept of best linear fit.

    This node finds the values of a and b that best fit 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 linear curve resulting from the linear fit algorithm:

    y [ i ] = a x [ i ] + b

    The following illustration shows a linear fit result using this node.

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: Not supported


    Recently Viewed Topics