Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: gauss1dfit - Constructor Up: mathematics - Module Previous: randomnumberstest - Function


gauss1dfitter - Tool



Package utility
Module mathematics


Postscript file available

Non-linear least-squares fit multiple 1-D Gaussians to vector

include "gfitgauss.g"

Constructors
gauss1dfit Construct a gauss1dfit tool
Functions
eval Evaluate a sum of Gaussians (usually the result of a fit)
fit Fit Gaussian(s) to y vector given x vector
getstate Get the state of the fitter
setcenter Set the center state
setcriteria Set the convergence criteria
setheight Set the height state
setmaxiter Set the maximum number of iterations
setstate Set the state of the fitter
setwidth Set the width state



Description

gauss1dfitter is a tool which allows the user to fit a Gaussian or multiple Gaussians to a vector given a vector of coordinate values (x). It remembers the state of the most recent fit. Repeated calls to the fit functions start from the current state. The tool also provides a function for evaluating the Gaussian parameters along a vector of x values.

At present, only fits to real data without constraints are supported.

The fits are carried out with double precision.

The form of a Gaussian is: hexp(-4ln 2((x-x0)/w)2) where h is the height, x0 is the center and w is the full width at half maximum. Multiple Gaussians are simply summed together to determine the best fit.



Example
- fitter := gauss1dfitter()
- x := [1:100]
- y := 5*exp(-4*ln(2)*(((x-40)/25)^2)) + 15*exp(-4*ln(2)*(((x-50)/8)^2))
- guess := [=]
- guess.height := [4.0,16.0]
- guess.center := [37.0, 55.0]
- guess.width := [28.0, 10.0]
- guess.maxiter := 15;
- fitter.setstate(guess)
- state := fitter.fit(x, y)
- print state.converged
T

This example begins by first constructing a gauss1dfitter tool. Then a vector is constructed which is the sum of 2 Gaussians extending over the given x range. The fitter needs an initial guess. This guess also sets the number of of components which will be fit. This is obviously contrived here since we know what the Gaussian parameters are. The maximum interations per invocation of fit is set to be 15. The setstate function is used to set the state as this initial guess and maxiter. We could have also used the setheight, setcenter, setwidth, and setmaxiter functions to change the state. The fit function is called with the given x and y values. This returns a state record. The state record indicates that this fit has converged.




next up previous contents index
Next: gauss1dfit - Constructor Up: mathematics - Module Previous: randomnumberstest - Function   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15