# Curve Fitting (Exponential) (G Dataflow)

Returns the exponential fit of a data set using a specific fitting method.

## 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: False

## 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.

## 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.

## 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.

## 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

## tolerance

Value that determines when to stop the iterative adjustment of the amplitude, damping, and offset.

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

How tolerance Affects the Outputs with Different Fitting Methods

For the Least Square and Least Absolute Residual methods, 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 amplitude, damping, and scale in two successive iterations is less than tolerance, this node returns the resulting amplitude, damping, and scale.

Default: 0.0001

## 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: 100

## 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

## parameter bounds

Upper and lower constraints for the amplitude, damping, and offset of the calculated exponential fit.

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

### amplitude min

Lower bound for the amplitude.

Default: -Infinity, which means no lower bound is imposed on the amplitude.

### amplitude max

Upper bound for the amplitude.

Default: Infinity, which means no upper bound is imposed on the amplitude.

### damping min

Lower bound for the damping.

Default: -Infinity, which means no lower bound is imposed on the damping.

### damping max

Upper bound for the damping.

Default: Infinity, which means no upper bound is imposed on the damping.

### offset min

Lower bound for the offset.

Default: 0

### offset max

Upper bound for the offset.

Default: 0

## method

The fitting method.

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
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 amplitude, damping, and offset of the exponential model by minimizing the residue according to the following equation:

$\frac{1}{N}\underset{i=0}{\overset{N-1}{\sum }}{w}_{i}{\left({f}_{i}-{y}_{i}\right)}^{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 exponential 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 amplitude, damping, and offset of the exponential model by minimizing the residue according to the following equation:

$\frac{1}{N}\underset{i=0}{\overset{N-1}{\sum }}{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 exponential 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 amplitude, damping, and offset using an iterative process, as shown in the following illustration.

The node calculates residue according to the following equation:

$\frac{1}{N}\underset{i=0}{\overset{N-1}{\sum }}{w}_{i}{\left({f}_{i}-{y}_{i}\right)}^{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 exponential fit
• yi is the ith element of y or the ith data value in a waveform.

Default: Least Square

## best exponential fit

Exponential 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

## amplitude

Amplitude of the fitted model.

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

## damping

Damping of the fitted model.

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

## offset

Offset of the fitted model.

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

This output 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

## 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.

## 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:

$\mathrm{residue}=\text{\hspace{0.17em}}\frac{1}{N}\underset{i=0}{\overset{N-1}{\sum }}{\left({f}_{i}-{y}_{i}\right)}^{2}$

where

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

## Algorithm for Calculating best exponential fit

This node uses the iterative general least square method and the Levenberg-Marquardt method to fit data to an exponential curve of the general form described by the following equation:

$f=a{e}^{bx}+c$

where

• x is the input sequence
• a is amplitude
• b is damping
• c is offset

This node finds the values of a, b, and c that best fit the observations (x, y).

The following equation specifically describes the exponential curve resulting from the exponential fit algorithm:

$y\left[i\right]=a{e}^{bx\left[i\right]}+c$

The following illustration shows an exponential fit result using this node.

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices