Finding out what initial guesses the curve fitting toolbox made for curve fit

6 visualizaciones (últimos 30 días)
Hi everyone, thank you for your time,
I am currently working on a code that inputs real-life indentation data to fit them through a curve fitting toolbox. The relevant code portion is as below:
f1 = fittype('a0+(a1-a0)*((0.491*exp(-0.908*sqrt((abs(a3)*x)/(C0^2))))+(0.509*exp(-1.679*sqrt((abs(a3)*x)/(C0^2)))))','problem','C0')
f = fit( Hx, Hy, f1, 'problem', C0, 'lower',[0,0,0])
As you can see, I have not specified starting conditions, because we work with different tissues that each have different local minima (which creates non-fits). So I am letting MatLab randomize the starting points ( coeffiecient a0,a1,a3) to get global minima.
I am currently using r2 comparison to choose the best results. What I am also interested is recording what initial values Matlab chose for a0,a1 and a3 for the better runs (higher r2) so that I can make separate codes for particular tissues with preset inital guesses.
Thank you all for your time.
  2 comentarios
Matt J
Matt J el 20 de Oct. de 2021
What I am also interested is recording what initial values Matlab chose for a0,a1 and a3 for the better runs (higher r2) so that I can make separate codes for particular tissues with preset inital guesses.
Why would the initial values be better for future presettings than the final solutions?
Muhtadi Zahin
Muhtadi Zahin el 20 de Oct. de 2021
Editada: Muhtadi Zahin el 20 de Oct. de 2021
I'm working with different biological samples. My idea is that I make versions of the code with different initial values corresponding with different biological tissues, so that the results are out more quickly. Also because I do not think that one set of initial values will work for all sample results.
As for intial value and not final values, I just think that the variability in biological data makes it better if I know a valid range of "casting net" to work on. Basically, I want to have a record of the range of initial values that best "caught" a range of fit-curves, if I'm making any sense.

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 20 de Oct. de 2021
Editada: Matt J el 21 de Oct. de 2021
I don't think there's anyway to dig out the initial guess generated inside fit(), but why not just specify your own random start point(s)? I can't imagine there's any advantage to letting fit() do it internally.
Also, note that your problem can be reduced to a single unknown (a3) as below. You might be able to do a simple one-dimensional parameter sweep for an accurate initial guess a3_0.
fun=@(a3) mdl(a3,Hx,Hy,C0); %1D function of a3
a3=fminsearch( fun, a3_0); %a3_0 = initial guess of a3
[~,coeffs]=fun(a3);
a0=coeffs(1);
a1=sum(coeffs);
function [resnorm,coeffs]=mdl(a3,x,y,C0)
x=x(:); y=y(:);
z=((0.491*exp(-0.908*sqrt((abs(a3)*x)/(C0^2))))+(0.509*exp(-1.679*sqrt((abs(a3)*x)/(C0^2)))));
opts=optimoptions('lsqlin','Display','off');
[coeffs,resnorm]=lsqlin(z.^[0,1],y,-[1,1],0,[],[],[0,-inf],[],[],opts);
end
  3 comentarios
Matt J
Matt J el 21 de Oct. de 2021
Editada: Matt J el 21 de Oct. de 2021
I'm not sure if discounting a0 and a1 in my code will work, because I need the values of coefficients a0 and a1 to use in separate equations to find poroelastic properties.
My proposed code doesn't discount a0 and a1. It just computes them at the very end, after a3 has been fit. Fitting a3, however, requires that you minimize a function of a3 (and only a3). Therefore, you only need an initial guess for a3 and not for the other two parameters..
I am not sure how to do the 2nd option, frankly.
It's just,
f = fit( Hx, Hy, f1, 'problem', C0, 'lower',[0,0,0],'StartPoint', rand(1,3))
This is the same as what fit() does by default when 'StartPoint' is not specified manually. Obviously, you could use randn() or other random distributions if you think they would make more sense.
Muhtadi Zahin
Muhtadi Zahin el 21 de Oct. de 2021
Thanks much. I'll try and follow this to my understanding.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by