Table Of Contents

Curve Fitting (Logarithm) (G Dataflow)

Last Modified: December 18, 2017

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

connector_pane_image
datatype_icon

base

Base of the logarithm.

Name Value Description
e 2.71828 Uses the natural logarithm.
10 10 Uses 10 as the base of the logarithm.
2 2 Uses 2 as the base of the logarithm.

Default: e

datatype_icon

y

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

datatype_icon

x

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

datatype_icon

weight

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.

datatype_icon

tolerance

Value that determines when to stop the iterative adjustment of the amplitude and scale.

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

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.

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

datatype_icon

parameter bounds

Upper and lower constraints for the amplitude and scale. 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.

datatype_icon

amplitude min

Lower bound for the amplitude.

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

datatype_icon

amplitude max

Upper bound for the amplitude.

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

datatype_icon

scale min

Lower bound for the scale.

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

datatype_icon

scale max

Upper bound for the scale.

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

datatype_icon

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.

Algorithm for the Least Square Method

The least square method of fitting finds the amplitude and scale of the logarithmic 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 logarithm 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 and scale of the logarithmic 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 logarithm 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 and scale of the logarithmic model 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 logarithm fit
  • yi is the ith element of y or the ith data value in a waveform.

Default: Least Square

datatype_icon

best logarithm fit

Y-values of the fitted model.

datatype_icon

amplitude

Amplitude of the fitted model.

datatype_icon

scale

Scale of the fitted model.

datatype_icon

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

residue

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.

Algorithm for Calculating best logarithm fit

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

f = a log c ( b x )

where

  • x is the input sequence
  • a is amplitude
  • b is scale
  • c is base

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

The following equation describes the logarithm function resulting from the logarithm fit algorithm:

y [ i ] = a log c ( b x [ i ] )

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

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices

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


Recently Viewed Topics