How do you go about guessing for fitting parameter initializations?
Ältere Kommentare anzeigen
The code is meant to fit this data to the equation σy = σ0 + k*d^(−1/2). So sigma_0 and k are the unknown parameters. This is all based on a fitting practice problem I found online related to yield stress of metals. How am I supposed to go about guessing the parameter initializations for p0. I found on previous examples I was just getting lucky.
Data:
Data = [0.006 334
0.011 276
0.017 249
0.025 235
0.039 216
0.060 216
0.081 194
0.105 182];
%Data = load('stress.txt');
d = Data(:,1);
sigma = Data(:,2);
figure
plot(d,sigma, 'go')
hold on
fun = @(p, d) p(1) + p(2).*d.^(-1/2);
p0 = [1 1];
params = lsqcurvefit(fun,p0,d,sigma);
stress_fit = fun(params,d);
plot(d,stress_fit, 'b');
hold off
Akzeptierte Antwort
Weitere Antworten (1)
John D'Errico
am 22 Jun. 2023
0 Stimmen
There is no magic way to guess parameter estimates for any nonlinear problem. Sorry, but true. And of course, if there was, then the fitting codes would use it. Oh well.
It helps if you understand what the parameters tell you about the shape of the curve. This helps by a MASSIVE amount, since then you can provide intelligent choices.
Lacking comprehension about the parameters, then you essentially are forced to rely on magic. And magic is never a good thing to rely on, unless your name is Harry, and you have your own magic wand.
In the example case you have posed, the model is LINEAR in the parameters. As such, you can use basic fitting tools that do not need starting values. This is a nice thing, but it relies on you understanding what makes a model linear in the parameters.
SOMETIMES, you can use a transformation of the problem. That is, in some problems, by taking the log of the model, the parameters will now enter linearly. Then you can use a solver able to handle such a fit. Again, no starting values will be needed, HOWEVER, the transformation will also do strange things to the noise structure in the probem.
IN desperate times, you can use tools like GA to try to minimze the errors. Since GA is a tool that tries to do a quasi-global search, it does not need starting values. But GA (and other solvers like it) comes with its own issues that you really need to understand to use it optimally.
I'm sorry. There is no magic solution that always works. Well, not unless you have a magic wand. Mine broke the other day, and the lead times on parts are quite lengthy. Lacking that, you need to understand the tools you are using, how the solvers work, and the differences between them. A good understanding of what those parameters do to your model is also important.
Kategorien
Mehr zu Get Started with Curve Fitting Toolbox 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!

