lsqcurvefit doesn't curve fit
Ältere Kommentare anzeigen
I have a model which I want to paramtrise using lsqcurvefit. I have 10 parameters that I must find and I have 10 pieces of data (or more) that I can call on. I set up my function that I want to minimise including the function which includes the model. When I use 10 points I get the message that a minimum is possible and when I plot the solution using the parameters and compare it against the experimental data, I get completely different curves, the solution should overly the points I get but that just isn't the case.
Any idea why this would happen?
Mat
Antworten (2)
Star Strider
am 13 Feb. 2019
0 Stimmen
Use as many data as you have. Also, nonlinear parameter estimation techniques are very sensitive to the initial estimates (that you give to the routine to start with), and an inaccurate set can cause the routine to end up in a local minimum rather than a minimum that is much closer to the correct parameters. Choosing the correct values can be challenging.
If you repeatedly have problems guessing the correct initial parameter values, use one of the Global Optimization Toolbox functions (such as the genetic algorithm ga function) to search out the best parameter set. Those take time, however they are usually succesful. (For ga, begin with a large initial population, so it has a better probability of discovering the best parameter set.)
16 Kommentare
Matthew Hunt
am 13 Feb. 2019
Star Strider
am 13 Feb. 2019
The MATLAB ga alfgorithm can actually be reasonably fast, although with 10 parameters, it’s best you find something else to do while it’s running.
Newton-Raphson is a root-finding algorithm. If you’re estimating a nonlinear system of algebraic equations and you want to find a set of parameters that will equate your equations to 0, use the fsolve function.
I’m still not sure what you’re doing. Expanding on a description of that could make it easier to converge on a solution.
Matthew Hunt
am 13 Feb. 2019
My first thought was to evaluat the model at the same points as the dataset and set this up as a nonlinear algebraic system of equations.
There is little or no distinction between that and what lsqcurvefit (or fsolve) is already doing. And it doesn't solve the problem because nonlinear equation solvers also rely on accurate initial parameter guesses, as you probably discovered when you tried Newton-Raphson.
It would help a lot if we could see the actual model function and data.
Matthew Hunt
am 13 Feb. 2019
Star Strider
am 13 Feb. 2019
@Matthew Hunt —
‘I want to do something more clever that just throw a genetic algorithm at the problem.’
A genetic algorithm is clever enough, if you have no idea what the correct initial parameter set should be.
Meanwhile, you still haven’t enlightened us as to what your actual problem is. We can keep guessing at a solution hoping (against all odds) to come up with the correct one by sheer chance, or you can let us help you with it.
I want to do something more clever that just throw a genetic algorithm at the problem...The model I want to fit, is quite a simpe one as it's analytically solveable.
@Matthew Hunt,
If the fit has an analytical solution, then using lsqcurvefit, or any other iterative solver, is not clever. You should just code the analytical solution algorithm.
Matthew Hunt
am 13 Feb. 2019
Matthew Hunt
am 13 Feb. 2019
Star Strider
am 13 Feb. 2019
Thanks for the paper. It’s in my clip file.
It would be easier to work with your code, since that seems to be where the problem is, and I can’t figure out what expression in that paper you’re using for your model.
Post your code, describe what it’s supposed to do in some detail, and describe what you want to do with it. Is it an optimization problem without data, a parameter estimation problem with data, or something else?
Matthew Hunt
am 13 Feb. 2019
Matthew Hunt
am 13 Feb. 2019
Matthew Hunt
am 13 Feb. 2019
Matthew Hunt
am 13 Feb. 2019
Matthew Hunt
am 13 Feb. 2019
Matthew Hunt
am 13 Feb. 2019
You could have a bug in your model function, such that it is not implementing the curve you that you think it is. What happened when you used your model function code to generate a curve with known parameters? Did the curve look as expected?
1 Kommentar
Matthew Hunt
am 13 Feb. 2019
Kategorien
Mehr zu Surrogate Optimization finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!