# Nonlinear Curve Fitting (Trust-Region Dogleg) (G Dataflow)

Uses the trust-region dogleg method to determine the set of parameters that best fit the input data set as expressed by a nonlinear function. You implement the nonlinear function using a strictly typed VI reference.

## stopping criteria

Conditions that terminate the fitting process.

This node terminates the fitting process if this node passes the maximum iterations threshold or reaches the tolerance threshold.

### maximum iterations

Maximum number of iterations that the node runs in the fitting process.

Default: 200

### tolerance

Minimum relative change in the weighted distance between y and the current fit.

Default: 1E-08

## data

Arbitrary values passed to the strictly typed VI reference that implements the nonlinear function.

## nonlinear function

Reference to the VI that implements the nonlinear function for the fitting model.

## y

Dependent values.

y must be greater in size than initial parameters. y must be the same size as x.

## x

Independent values.

x must be greater in size than initial parameters. x must be the same size as y.

## weight

Weights for the observations.

If weight is unwired, this node sets all elements of weight to 1. If the length of weight does not equal the length of y, this node forces the lengths to be equal by padding the end of weight with 1 or ignoring the extra elements at the end of weight. If an element in weight is less than 0, this node uses the absolute value of the element.

## initial parameters

Initial guess for a solution.

The success of the nonlinear curve fit depends on how close initial parameters is to the solution. Therefore, use any available resources to obtain good initial guess coefficients to the solution before you use this node.

## 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 numeric limits for the parameters being optimized.

### minimum

Smallest allowed values of the parameters being optimized.

The input must be empty or the same size as initial parameters. This input must be the same size as maximum. This input does not allow exceptional values, such as Inf, -Inf, or NaN.

Each element in minimum must be less than or equal to the corresponding element in maximum. If an element in minimum is equal to the corresponding element in maximum, this node uses the value of the element as the constant value of that variable throughout the curve fitting.

### maximum

Greatest allowed values of the parameters being optimized.

The input must be empty or the same size as initial parameters. This input must be the same size as minimum. This input does not allow exceptional values, such as Inf, -Inf, or NaN.

Each element in maximum must be greater than or equal to the corresponding element in minimum. If an element in maximum is equal to the corresponding element in minimum, this node uses the value of the element as the constant value of that variable throughout the curve fitting.

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

## best nonlinear fit

Values of the nonlinear function that correspond to the independent values.

## best fit parameters

Parameters that minimize the weighted mean square error between the solution vector and the observed dependent values.

## covariance

Matrix of covariances.

The element in the jth row and kth column cjk is the covariance between ai and ak, where ai and ak are the jth and kth element in best fit parameters, respectively. cjj is the variance of aj.

Algorithm for Calculating covariance

This node computes the covariance matrix C using the following equation: $\mathbf{C}={\frac{1}{2}D}^{-1}$, where D is the Hessian of the function with respect to the values in best fit parameters.

## number of function calls

Number of times that this node called the nonlinear function in the fitting process.

## 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 square error between best nonlinear fit and y.

## Nonlinear Curve Fitting Model

The following equation defines the nonlinear curve fitting model for this node: y[i] = f(x[i], a0, a1, a2, ...), where a0, a1, a2 , ... are the parameters.

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported

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