Last Modified: August 13, 2019

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

Array of dependent values. The length of **y** must be greater than or equal to the number of unknown parameters.

Independent values. **x** must be the same size as **y**.

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.

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

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 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**, **power**, and **offset** in two successive iterations is less than **tolerance**, this node returns the resulting **amplitude**, **power**, and **offset**.

**Default: **0.0001

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.

**Default: **No error

The upper and lower constraints for the amplitude, power, and offset. If you know the exact value of certain parameters, you can set the lower and upper bounds of those parameters equal to the known values.

Lower bound for the amplitude.

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

Upper bound for the amplitude.

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

Lower bound for the power.

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

Upper bound for the power.

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

Lower bound for the offset.

**Default: **0

Upper bound for the offset.

**Default: **0

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

Algorithm for the Least Square Method

The least square method of fitting finds the **amplitude**, **power**, and **offset** of the power model by minimizing **residue** according to the following equation:

$\frac{1}{N}\underset{i=0}{\overset{N-1}{\sum}}{w}_{i}{({f}_{i}-{y}_{i})}^{2}$

where

*N*is the length of**y**or the number of data values in a waveform*w*_{i}is the*i*^{th}element of**weight***f*_{i}is the*i*^{th}element of**best power fit***y*_{i}is the*i*^{th}element of**y**or the*i*^{th}data value in a waveform

Algorithm for the Least Absolute Residual Method

The least absolute residual method finds the **amplitude**, **power**, and **offset** of the power model by minimizing **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*w*_{i}is the*i*^{th}element of**weight***f*_{i}is the*i*^{th}element of**best power fit***y*_{i}is the*i*^{th}element of**y**or the*i*^{th}data value in a waveform

Algorithm for the Bisquare Method

The bisquare method of fitting finds the **amplitude**, **power**, and **offset** of the power model 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}{({f}_{i}-{y}_{i})}^{2}$

where

*N*is the length of**y**or the number of data values in a waveform*w*_{i}is the*i*^{th}element of**weight***f*_{i}is the*i*^{th}element of**best power fit***y*_{i}is the*i*^{th}element of**y**or the*i*^{th}data value in a waveform.

**Default: **Least Square

Y-values of the fitted model.

Amplitude of the fitted model.

Power of the fitted model.

Offset of the fitted model.

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

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

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.

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

$f=a{x}^{b}+c$

where

*x*is the input sequence*a*is**amplitude***b*is**power***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 power function resulting from the general power fit algorithm:

$y[i]=a{\left(x\left[i\right]\right)}^{b}+c$

**Where This Node Can Run: **

Desktop OS: Windows

FPGA: Not supported

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