Faster Numerical Integral implementation

32 Ansichten (letzte 30 Tage)
Hao
Hao am 4 Okt. 2013
Bearbeitet: Meysam Mahooti am 5 Dez. 2019
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!

Antworten (2)

Walter Roberson
Walter Roberson am 5 Okt. 2013
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 Kommentar
Hao
Hao am 5 Okt. 2013
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.

Melden Sie sich an, um zu kommentieren.


Meysam Mahooti
Meysam Mahooti am 27 Nov. 2019
Bearbeitet: Meysam Mahooti am 5 Dez. 2019
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

Community Treasure Hunt

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

Start Hunting!

Translated by