Table Of Contents

Curve Fitting (Gaussian Peak) (G Dataflow)

Version:
Last Modified: August 28, 2017

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

connector_pane_image
datatype_icon

initial guess

Initial guesses of the amplitude, center, standard deviation, and offset for use in the iterative algorithm.

If initial amplitude, initial center, initial standard deviation, or offset is NaN, this node calculates the initial guess automatically.

datatype_icon

initial amplitude

Initial guess of the amplitude.

Default: NaN

datatype_icon

initial center

Initial guess of the center.

Default: NaN

datatype_icon

initial standard deviation

Initial guess of the standard deviation.

Default: NaN

datatype_icon

offset

Initial guess of the offset.

Default: NaN

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

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, center, standard deviation, and offset.

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

center min

Lower bound for the center.

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

datatype_icon

center max

Upper bound for the center.

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

datatype_icon

deviation min

Lower bound for the standard deviation.

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

datatype_icon

deviation max

Upper bound for the standard deviation.

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

datatype_icon

offset min

Lower bound for the offset.

Default: 0

datatype_icon

offset max

Upper bound for the offset.

Default: 0

datatype_icon

method

The 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, center, standard deviation, and offset of the Gaussian model by minimizing the 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 Gaussian 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, center, standard deviation, and offset of the Gaussian model by minimizing the 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 Gaussian 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, center, standard deviation, and offset 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 Gaussian fit
  • yi is the ith element of y or the ith data value in a waveform.

Default: Least Square

datatype_icon

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.

datatype_icon

best Gaussian fit

Y-values of the fitted model.

This output can return the following data types:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers.
datatype_icon

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.

datatype_icon

center

Center of the fitted model.

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

datatype_icon

standard deviation

Standard deviation of the fitted model.

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

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.

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

Algorithm for Calculating best Gaussian fit

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

f = a exp ( ( x μ ) 2 2 σ 2 ) + c

where

  • x is the input sequence
  • a is amplitude
  • μ is center
  • σ is standard deviation
  • c is offset

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

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

y [ i ] = a exp ( ( x [ i ] μ ) 2 2 σ 2 ) + c

The following illustration shows a Gaussian 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