0

I am using the fit function to fit a curve with quite a few parameters. It turns out that in my problem it is quite hard to predict the parameter ranges that the value should lie in (it would require a lot of pre-analysing of the data). In addition, the accuracy level I need for the fit is quite high. I have tried and I can't really get around these two facts, they are just set by my physics problem at hand.

However one upside is that I don't really have run-time issues. So what I would like to do is sacrifice run-time for a higher fit accuracy. Essentially I would just like the program to run longer and sample more of the parameter space.

I have read the fit options page. The parameters DiffMinChange, DiffMaxChange, MaxIter and TolX seemed promising at first, but from what I have gathered none of these do what I want. Have I missed something? Should I be using a different function maybe?

Dev-iL
  • 23,742
  • 7
  • 57
  • 99
Wolpertinger
  • 1,169
  • 2
  • 13
  • 30
  • 1
    It may be that `fit` is not the right tool for your problem. Consider that what "fitting" entails is solving some optimization problem, where the cost function is SSE or RMSE etc. There are all sorts of methods to solve optimization problems (like gradient descent, grid search etc.). What I would suggest is looking into the optimization toolboxes ([1](https://www.mathworks.com/help/gads/index.html), [2](https://www.mathworks.com/help/optim/index.html)), trying to define your own cost function that may or may not be more costly to compute but more accurate in the long run. – Dev-iL Dec 20 '16 at 08:26
  • @Dev-iL Dear Devil (didnt think I would ever write that, but here we go ;) ), thank you for your response! I'll try to find something in the optimization toolboxes. Can I just ask what SSE and RMSE are? As you can probably tell I am rather unexperienced with this sort of thing. The reason I was naively expecting some sort of easy-to-use pre-made function for this sort of thing is that Mathematica's non-linear-model-fit worked quite well immediately. I saw that MATLAB has a nlm function too, do you think that would be a better option? – Wolpertinger Dec 20 '16 at 08:42
  • SSE and RMSE are possible metrics for the "goodness of fit". If you're asking about them, you should definitely do some reading about fitting and optimization before proceeding any further. You can start by reading the [about pages](https://www.mathworks.com/help/gads/getting-started-with-global-optimization-toolbox.html) in the toolboxes I linked. Also, it sounds like you aren't using the curve fitting tool (`cftool`) - which makes it a bit faster to get things going. Unfortunately, I'm unfamiliar with "`nlm`" in MATLAB. – Dev-iL Dec 20 '16 at 09:03
  • @Dev-iL thanks for the references! The cftool doesn't seem to be the right thing for me because my model is a double Lorentzian, which I don't think is contained in there. By nlm I meant this: https://de.mathworks.com/help/stats/fitnlm.html – Wolpertinger Dec 20 '16 at 23:38

0 Answers0