Improve fit quality for a custom function with near-perfect starting values
Mostra commenti meno recenti
I'm trying to fit data with a relatively complicated custom function (combined logistic+linear function; combined effect of my data+noise). By trail-and-error I can manually find a good fit (indicated below), but I want MATLAB to do the final fine-tuning. Instead, the MATLAB fit is way worse than what I can do manually. As this takes minutes to do by hand and I will need to process hundreds of images, I really want to automate this.
This is the starting fit I provide manually:

This is the fit after MATLAB is done (using the manual fit values as startpoint):

I tried:
- Setting lower and upper bounds
- Parameter scaling (all coefficients between 1E-2 and 1E2)
- Changing algorithm
- Setting DiffMinChange and DiffMaxChange to small values
- Changing TolX and TolFun
The main thing I don't understand is why MATLAB worsens the fit. Especially with low DiffMinChange and DiffMaxChange, I would expect MATLAB to give the starting fit or something better.
In case people want to try for themselves, below I provide the data and custom function. The data-to-fit is in 'data.txt', while the function I use to fit it is:
I=@(Ac,b,AE,bg,bgx,x) AE.*(1./(1+1E15./Ac.*exp(-b.*x)))+bg+bgx.*x;.
The manual startpoint is
start=[1.75 0.065 14 16 0.015];
To help with interpretation of the function:
- It is a logistic function '1/(1+1E15./Ac*exp(-b*x))',
- a scale-factor for the logistic function 'AE', (the 1E15 is to scale the parameter)
- a background offset 'bg', and
- a background slope 'bgx'.
2 Commenti
Star Strider
il 5 Giu 2018
Modificato: Star Strider
il 5 Giu 2018
Which of: (Ac,b,AE,bg,bgx,x) are your independent variable, and which are the parameters?
Are there any constraints on the parameters?
Pieter Hamming
il 6 Giu 2018
Modificato: Pieter Hamming
il 6 Giu 2018
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Genetic Algorithm in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
