How to speed up function approximation?
Afficher commentaires plus anciens
I have a code in MATLAB2016:
...
tic
is_t1(:,i)=(is_t1(:,i)/mmax);
[f,r2]=fit(tr,is_t1(:,i),'1-b*exp(-((a*x)/(var_c)))','StartPoint',[0.8 0.8]);
T1(i)=-(var_c*log(-(0.6321 – 1)/f.b))/f.a;
toc
...
end
Its execution time: ~0,031s
Number of approximation points in a given task: ~7000-10000
How to ,speed up this operation?
Thanks for any help
Réponse acceptée
Plus de réponses (2)
Chris
le 19 Août 2019
0 votes
I dont have those toolboxes but often you can start an optimization problem with a randomly selected sub-set of data run for a short time to get a better initial guess before running the algorithm over all your data. YMMV. Take care with this and make sure you understand your data and how you are modeling it.
1 commentaire
Adrian T
le 19 Août 2019
Yair Altman
le 19 Août 2019
0 votes
It may be useful to replace the string with a function handle.
Also, setting the convergence tolerances to smaller values than the defaults might converge faster without a meaningful degradation of the result.
Lastly, read https://undocumentedmatlab.com/blog/speeding-up-builtin-matlab-functions-part-1 where I discuss different ways of significantly speeding-up the fitdist function. It's not the same as your fit but similar ideas can possibly also be useful in your case.
1 commentaire
Adrian T
le 19 Août 2019
Catégories
En savoir plus sur Elementary Math dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!