Multi-dimensional Fitting
46 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Muhammet Dabak
el 25 de Dic. de 2019
Comentada: Muhammet Dabak
el 27 de Dic. de 2019
I have 3 parameters for my function. Let's say f(x,y,z)=(a*x+b)*exp(-y/c)*(z^2+d) (Or i have n parameters).
I constructed the custom function because I know the behavior of the function (that I desire).
I have many samples(around 5000). For example f(1000,10,2)= 35;
Is there a method to fit these samples into a shape,solid (for 3 parameters case) ?
Or is there a method that to find the coefficients (a,b,c,d in this case) for my custom function using all my samples?
The answer doesnt have to be a specific for 3 parameter case, i need actually a solution for n parameters case.
(I know Matlab has curve fitting and surface fitting tools but no more dimensions.)
Any support will help me, thanks.
0 comentarios
Respuesta aceptada
Walter Roberson
el 25 de Dic. de 2019
You cannot use cftool it supports at most two independent variables and on dependent variable. You can, however, use your custom equation with fit() from the Curve Fitting Toolbox, or you could use nonlinear least squares https://www.mathworks.com/help/optim/nonlinear-least-squares-curve-fitting.html
fit() is often surprisingly efficient at what it does, and often generates coefficients that are close enough to optimal to be "good enough" for practical purposes.
However, in equations that have two or more major basins of attraction, fit() will typically go with the larger basin even when the smaller basin has a significantly better fit. Adding upper and lower bounds on the "reasonable" values of parameters can help a lot.
I would predict that the in your sample equation, the c value would tend to vary a lot. You do not have have an additive constant so the fitter would tend try to raise or lower the overall height by driving c large, but large values of c lead to small -y/c leading to near 1 value of exp() and relatively large changes in c have small effects, making it difficult to locate the best c value. This is a common problem for equations with exp() and a multiplicative coefficient inside.
5 comentarios
Walter Roberson
el 27 de Dic. de 2019
If the first term cannot be have a negative coefficient then put in bounds on the values.
Más respuestas (2)
Muhammet Dabak
el 25 de Dic. de 2019
Editada: Walter Roberson
el 26 de Dic. de 2019
1 comentario
Walter Roberson
el 26 de Dic. de 2019
You are right, fit() cannot be used for 3 or more independent variables. You will need to use a nonlinear least squares such as https://www.mathworks.com/help/optim/ug/lsqcurvefit.html .
Unfortunately with the random data I generated, lsqcurvefit did not do a good job. I am experimenting further.
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!