Faster Numerical Integral implementation
15 ビュー (過去 30 日間)
古いコメントを表示
I'm writing a program for finding the min of GMM. However, there is a lot of numerical integration in my GMM function and that's slowing my program down. I tried to write my own integration function using the Simpson's method. However, the values aren't very accurate compared with matlab's builtin integral function. I'm wondering what method does the builtin integral function use. Maybe there is a faster way to implement it? Thanks!
0 件のコメント
回答 (2 件)
Walter Roberson
2013 年 10 月 5 日
The different routines have different strengths. For example some of them cannot infinite range and others can. Some of them cannot handle a singularity at all and others can in some conditions.
The numeric integration routines are not able to analyze the function being integrated: they can only sample the outputs at particular locations and try to make guesses from there. The symbolic integration routines (Symbolic Toolbox) are able to examine the function to better figure out where the limitations might lie.
Does the function to be integrated have a closed form integral? If so then if you have access to the symbolic toolbox, do the symbolic integration once and use matlabFunction() to convert the result to an anonymous function that can be evaluated numerically.
Some numeric integration routines can work better if they have access to the gradient, so you could pre-calculate the gradient function and supply that to integration.
Meysam Mahooti
2019 年 11 月 27 日
編集済み: Meysam Mahooti
2019 年 12 月 5 日
You can use my Runge-Kutta_Fehlberg(RKF78) implementation which is faster and more accurate than MATLAB ODE45 function.
Moreover, you can use my Radau||A implementation for fast and precise numerical integration.
options = rdpset('RelTol',1e-13,'AbsTol',1e-16);
% options: numerical error tolerance
[t,yout] = radau(@Accel,(0:Step:N_Step*Step),Y0,options);
% @Accel: function handle
% (0:Step:N_Step*Step): time span of integration
% Y0: Initial Values
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!