3.137 FAQ-808 Why my peak fitting with user-defined function is slow? How to speed it up?

Last Update: 7/29/2018

The main reason of the slowness is Peak Gravity Center under Result: Configure Report: Peak Properties of Fit Peaks page of Peak Analyzer dialog. This option is checked by default. Origin's built-in peak fitting functions provide analytic solutions and thus calculates the Peak Gravity Center. However, user-defined fitting function doesn't have an analytic solution so it calculates Peak Gravity Center in a numeric way, which makes the fitting process slow.

Another reason is Fitted Peak Area under Result: Configure Report: Peak Properties of Fit Peaks page. Origin uses zero Moment to calculate the analytic area, which is also time-consuming.

To speed up the fitting process, you can uncheck Peak Gravity Center and Fitted Peak Area in Peak Analyzer. It will be very fast then. If you know the analytic solution for Peak Gravity Center and Fitted Peak Area, you can add a section in FDF file manually. Take the following fitting function for example, y = y0+ f \frac{A}{\frac{2w}{1+e^{s(x-x_c)}}}*\sqrt{4\frac{Ln2}{\pi}}*e^{-4Ln({\frac{x-x_c}{\frac{2w}{1+e^{s(x-x_c)}}})^2}}+
(1-f)\frac{\frac{2A}{\pi*(\frac{2w}{1+e^{s(x-x_c)}})}}
{1+4(\frac{x-x_c}{\frac{2w}{1+e^{s(x-x_c)}}})^2}

Peak Gravity Center and Fitted Peak Area are x_c and A respectively. So you can add following section to the end of FDF file:

[Moments] 
mz0 = A 
mz1 = xc
mc2 = N.A.
mc3 = N.A.
mc4 = N.A.


Notes: Note that selecting the Peak Properties,Peak Skew, Peak Excess, 3rd Order Moment, 4th Order Moment, may also be time-consuming. Please pay attention when you are using a user-defined function

Keywords:User defined fitting function, slow, peak analyzer, speed up