[Math] Gaussian Curve Fitting – Parameter Estimation

estimationstatistics

I was redirected here because someone in SO pointed out this is more of a math question than a programming question:

I have to fit a Gaussian curve to a noisy set of data and then take it's FWHM for a certain application. I used MATLAB to demo the concept, and curve fitting in MATLAB is extremely easy.

However, I eventually have to translate the code into Java/Android. I tried looking for libraries in Android that would help me fit a Gaussian curve to data set, but I couldn't find anything. Consequently, I started trying to learn all the math involved so I could do it manually.

My question: How do I go about estimating the three parameters (center, width, height) for a single-term gaussian model? I tried looking into the Expectation-Maximization algorithm but that went way over my head.

In general, I assume it would have something to do with error minimization? I'm just having trouble figuring out the step-by-step method of fitting a gaussian curve to my data.

Thanks for the help! Alec

EDIT:

One of the things I tried already involved taking the natural log of my data, fitting a parabola to the result using LSQR, and then transforming back. However, the results I'm getting aren't accurate, probably because this method is biased in some way or another.

If you don't know how to do parameter estimation, do you have any other suggestions of fitting a curve to my data? (Remember, it has to be manual since Android seems to be fairly limited on it's statistics libraries)

Best Answer

There is a straightforward method (no need for initial guess, no iterrative process). The program is short and very easy to write : Listing on page 7 in this paper : http://fr.scribd.com/doc/14674814/Regressions-et-equations-integrales

Note: The algorithm on page 7 is only the part giving the two main parameters (center, width). Then, computing the third parameter (amplitude), requires only a linear regression.

LATTER ADDITION (answer to dashesy's request) :

enter image description here

Numerical example (screen copy) :

enter image description here

Details of computation :

enter image description here