Faster Numerical Integral implementation

조회 수: 26 (최근 30일)
Hao
Hao 2013년 10월 4일
편집: Meysam Mahooti 2019년 12월 5일
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!

답변 (2개)

Walter Roberson
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.
  댓글 수: 1
Hao
Hao 2013년 10월 5일
Thanks for your reply! Unfortunately I don't think the integrand has a closed form integral. However, I think the gradient can be easily computed. How exactly would I use the gradient to help compute the numerical integration?
It's only a single integral with one variable. But I'm trying to find the min and therefore would have to iterate it many times (on orders of 10,000) with different parameter values. And then repeat this process for 100 or 1000 times as it's a monte carlo study.

댓글을 달려면 로그인하십시오.


Meysam Mahooti
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

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by