Getting inconsistent results for fitting different series of data to a nonlinear function

I have 15 series of experimental data taken at different frequencies. I also have a function which we think can describe the data. I am trying to fit each series of data which is taken at different frequency domains to the function and obtain the value of the fitting parameters (I have 4 fitting parameters) and use the obtained values of the fitting parameters to calculate the efficiency of the system by another equation and compare it with the experimental efficiency. The problem that I encounter is for about 5 series of data, the obtained fitting parameters make sense physically and the obtained theoretical effciency is consistent with the experimental efficiency which is good. For 3 series of data the fitted curve is good but the calculated theoretical efficiency from the obtained fitting parameters is less than experimental efficiency which is weird (by a factor of 2). And for about 5 series of data the fitted curve is not very good and it doesn't fit data well at the bottom but the calculated effciency from the fitting parameters is consistent with the experiment. I have tried many algorithms and approaches (including all the solvers compatible with my problem in optimiztion and curve fitting toolbox with their different algorithms) to solve the problem but I am still struggling.
I am wondering are there any thoughts or suggestions?
Thank you in advance!

Answers (1)

Nonlinear curve fitting often encounters local minima.
Some kinds of nonlinear systems are notoriously difficult to fit properly -- especially sums of Gaussians. In general if you have a nonlinear system with multiple distinct peaks, it is common to effectively end up fitting one of the peaks and treating the other like noise.
Whether the peaks for a nonlinear system can be fit well depends a fair bit on the system... which you did not happen to describe. So the only advice we can give you is to try multistart methods.

3 Comments

Thank you so much for your help. What I have is a nonlinear system with multiple distinct peaks. By "it is common to effectively end up fitting one of the peaks and treating the other like noise", do you mean even if the data for other peaks is not noise, we can only separate the data for one peak and fit only that part (to restrict the problem to one Gaussian and not a series of Gaussians)? Indeed, what I have for the fitting function includes a fraction where I do have exponential function in both nominator and denominator and also I have exponential function of a series of Gaussian functions where the fitting parameters are the amplitude, width of each Gaussian and the distance between this Gaussians. I have attached my data, fitting code, fitting function and two images to show you how it fits for these different data series (I have incuded the code for one of these data series). Indeed, in what I have attached I can increase the startingpoint for fitting parameter "a" and get slightly better fitted curve at the bottom but the obtained value for the fitting parameter then doesn't make sense physically. And at the end of the day, I can never get a good fit at the bottom even by increasing "a" to infinity. I appreciate your comments on that.
I have also tried multistart and global search and merely all of their solvers and algorithms and it has not solved the issue. Indeed, I do get close or same results by using the local solvers and multistart (globalsearch), here is the link to another question that I asked about getting same results https://www.mathworks.com/matlabcentral/answers/1704050-obtaining-close-results-with-and-without-using-multistart-and-globalsearch-for-fitting-data-to-a-non?s_tid=mlc_ans_email_view#answer_950020
Thank you in advance!
Update:
I tried fitting only one peak but I do have the same issues as before. I have also tried multistart option and I am getting the same results as the local solver by using multistart.
The data points you show in the "not fill well at the bottom" are so steep that I do not think you can realistically fit any function to those, except possibly piecewise.
To get that kind of steepness, you pretty much need to be using a gaussian with high phase, one per segment -- but sum of gaussians is quite difficult to fit.

Sign in to comment.

Asked:

on 25 Apr 2022

Commented:

on 7 May 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!