GAUSSFIT Function
Standard Library function that fits a Gaussian curve through a data set.
Usage
result = GAUSSFIT(x, y[, coefficients])
Input Parameters
x—A real vector containing the values of the independent variable.
y—A real vector containing the values of the dependent variable. Should be the same length as x.
Output Parameters
coefficients—(optional) A six-element vector with the coefficients A0 through A5 of the equation described in the Discussion section.
Returned Value
result—A real vector containing the dependent y values of the fitted function.
Keywords
None.
Discussion
The GAUSSFIT function fits y = F(x), where:
F(x) = A0 * EXP(-z2/2) + A3 + A4x + A5x2
and:
z = (x - A1)/(A2)
GAUSSFIT calls the POLY_FIT function to fit a straight line through the data for the purpose of determining estimates of the height, center, orientation, and width (approximately 1/e) of the Gaussian function to be fitted to the data.
These estimated parameters—along with the constant, linear, and quadratic coefficients of the straight line polynomial—are sent to the CURVEFIT function as trial coefficients of the Gaussian function. CURVEFIT uses a nonlinear least-squares method to fit a function with an arbitrary number of parameters. Any nonlinear function can be fitted as long as the partial derivatives of the function are known or can be approximated.
The peak or minimum of the Gaussian function returned will be located at the index of the largest or smallest value, respectively, in the y vector.
See Also