Search code examples
gaussianoriginlab

How can I add the Gaussian fit function back to originlab?


I needed to do a project for school to fit multiple peaks using the Gaussian function. The problem is that I remove the function accidentally from the peak functions list.This is preaty much all am I seeing. I don't know how to add it back and I didn't find anything else on google. Maybe because this is not something people usually do.

enter image description here When I press the "add" button I don't see anything in the folder. enter image description here But when I look directly in the folder I see the function right there. Maybe it is a Gaussian function for something else, not peak fit. Does anybody know how I can fix this? enter image description here


Solution

  • try using ordinary least squares ols curve fitting to interpolate a line between the two peaks

      # Fit the data to the gaussian function.
        fit_func = lambda p, x: p[0]*np.exp(-0.5*((x-p[1])/p[2])**2) + p[3]
        err_func = lambda p, x, y: fit_func(p, x) - y
        p0 = [max_counts, max_location, sigma, baseline]
        p, success = optimize.leastsq(err_func, p0[:], args=(x, y))
        
        # Get the parameters of the Gaussian function.
        max_counts, max_location, sigma, baseline = p