Fit model data
I have a very naive question about the find_fit
model. Is there some way to choose the "best" one? For example, in this simple situation:
R = [[0,1],[4,2],[8,4],[12,8],[16,16],[20,32],[24,64],[28,128],[32,256]]
p = scatter_plot(R)
p.show()
model(x) = 2^(a*x)
find_fit(R,model)
It will return a==0.25
. But for choosing this model 2^(a*x)
, of course, I already know the answer. If you choose something more generic that makes more sense like
model(x) = a^(b*x)
It will return a == 1.1017945777232188, b == 1.7875622665869968
. So I was wondering if there is a way to get the optimized model for it.
Many thanks.
Up to a small numerical difference the results are the same, because for the second set of parameters $a^b \approx 2^{1/4}$. What is the question?
You are trying to reduce to computation a choice among a (nn-enumerable) infinite set of possible models. This is the subject of statistics (among other) ; it is usually foolish to tackle this question without prior subject matter knowledge about the origin of the data you are trying to model.
Furthermore, the meaning of "best fit" is far from obvious : smallest error ? Smallest squared error ? Smallest predictive error ?
Do you want to use it for further prediction ? If so, can you express your desired performance in terms of (predictive) error metrics ? In terms of distribution of these errors ? In terms of maximal error ? This is highly dependent of the goal(s) you have...
If you take into account the complexity (or (lack of) parsimony) of a model, lots of choice have to be made..