Search code examples
c#curvedata-fittinggauss

Fitting a gaussian function to set of points


In order to find the FWHM I need to find a Gaussian f corresponding to a set of (x,f(x)) values. The available fitting methods (I'm restricted to C#) assume the solution to be a polynomium of n'th degree (or that's what I've been able to find so far). I'm wondering if there exists a specialized fitting method/scheme aimed at finding Gaussians. Or is there a generalized method out there that converges fast? I can provide a good guess for the middle of the bell curve and its height but no more than that.


Solution

  • Solved this by observing that

    ln(y) = ln(a) - ½(x-b)^2/c^2

    which gives

    c = sqrt(½(x-b)^2/ln(a-y))

    So with a and b known it was a no-brainer :)