MATLAB Answers

Use of fminsearch in logscale

23 views (last 30 days)
Sunethra Pitawala
Sunethra Pitawala on 27 Sep 2021 at 11:16
Edited: Matt J on 28 Sep 2021 at 8:45
I am trying to fit 3 Gaussians to data (a curve) and the model parameters of the gaussians (mu, std and amplitude) are obtained from a curve drawn on a logscale. i.e. losspace (-4,1, 100). I do not get a good match between the Gaussians and my data.
When the modelparameter are obtained from a curve darwn on a linear scale , it works fine. Using 'fminsearch'.
Any suggestions, please?

Answers (1)

Matt J
Matt J on 28 Sep 2021 at 7:24
Edited: Matt J on 28 Sep 2021 at 8:45
Well, that could make sense. On a log scale, much of your data could be either very far away from the central portion of the 3 Gaussian lobes or clustered very close together, and therefore don't provide very informative measurements. So, use a linear scale to sample the curves. Or, sample on the log scale more finely and apply weights to your objective function, so that the samples near the central lobes get more priority.
Also, fminsearch is probably not a good tool to use with the number of unknown variables that you have. You should probably use lsqcurvefit instead, ideally with SpecifyObjectiveGradient=true..


Community Treasure Hunt

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

Start Hunting!

Translated by