Automatic selection of best curve-fitting equation type?

12 次查看(过去 30 天)
I have numerous sets of 3D data (each a matrix of 45 z values in a matrix of 5x by 9y). Is Matlab Curve Fitting Toolbox able to calculate for itself the best form of equation fit for each dataset z = f(x,y) or do I manually have to go through each possible form of equation to identify the most appropriate output?

回答(2 个)

jgg
jgg 2016-1-12
I don't think there's a function which is like "best fit my data" (for a variety of reasons, but the simplest is that model selection is a difficult process) but I can think of a couple of options.
  • Option 1: Choose a flexible parametric family you think will likely capture the possible shapes. For instance, a high-order polynomial values for x and y will likely do this in a linear regression context. You can also use something like stepwise model selection to choose the right fit.
  • Option 2: run several different models that you like for each value, then select the "best" one according to some criterion you have. This has the upside of being able to try several families, at the expense of lots of computation time
  • Option 3: Try a non-parametric estimation. Non-parametric models don't specify a functional form; there are some built in to Matlab but also a bunch on the file exchange if you want to do some research and reading on your setting.
  1 个评论
Walter Roberson
Walter Roberson 2016-1-12
High order polynomials tend to have very high numeric error unless the data is clustered together sufficiently.
And in practice, fitting a high order polynomial seldom returns 0s for the higher coefficients when a lower-order polynomial would be more appropriate. In my tests I have only seen leading 0s when all of the input data is 0.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2016-1-12
No, what you are asking is not mathematically possible.
For any given finite set of points, there are an infinite number of different functions that will fit the points exactly (to within roundoff error).
I would say that there are "even more" functions that fit if you presume that there is some inexactness or noise in the measurements, but since it is the same order of infinity, Aleph 1, the two infinities turn to be the same size.
With there being mathematically an infinite number of matching functions, there is no mathematical way to determine what the "right" function is. As far as Mathematics can determine, the next value in the sequence is always 19.
Therefor, in order to do curvefitting, you need to restrict yourself to a small number models that you have some reason to expect might underlie the generating process. You can then fit with those models and examine residues. As long as you remember that having a smaller residue does not necessarily mean that something is the real model: round off error with the "real" model can get pretty large even if there is no noise to take into account (and there probably is noise.)
If you have sufficient data points it can be useful to fit upon a subset of the data, and use that to predict values for a different subset and see how well it does: this reduces problems with "overfitting".
Having plausible models ahead of time can cut way down on your getting stuck with garbage models that happen to fit with marginally better residue on the data tested. And if you are using this kind of fitting to derive possible models, it is incumbent upon you to turn the model around into something you can test, and then make the test. If you find two models to seem to have the same explanatory power on the data you have, then compare the models to find conditions under which they would have a noticeably different result, and then go back and create those conditions to see which of the models works in practice. And then try to explain the physical mechanisms that would favour the one over the other.
Curvefitting should be used to get parameters for known models, or should be used as guidance in refining experiments to allow more accurate models to be designed, but should never be used to select the "right" model out of wide open slate.

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by