[R] integration

Ravi Varadhan rvaradhan at jhmi.edu
Tue Dec 18 15:46:47 CET 2007

Hi Davide,

It is difficult to say what the problem is without knowing more about the nature of the integrand.  So, you should do a couple of preliminary things before attempting compute the integral.

First, is the integral is finite? You should establish this.  Second, plot the integrand over the entire interval.  Then you need to think about the following: Is the integrand unimodal, with the mass concentrated over a small region? Or is it multimodal? Does it have thick tail?

Assuming that the integral is finite, you could try a few things:
1.  Divide the interval of integration into several small intervals (say, 10 or 100), and then use integrate() on each and then add up the results.  You can make this process more efficient if you know where the mass is concentrated.
2.  Transform the integrand.
3.  Try a simple trapezoidal rule quadrature.



Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of dlavecchia at tiscali.it
Sent: Monday, December 17, 2007 11:03 AM
To: r-help at r-project.org
Subject: [R] integration

Dear All,
I need to perform a numerical integration of one dimensional 
fucntions. The extrems of integration are both finite and the functions 
I'm working on are quite complicated. I have already tried both area() 
and integrate(), but they do not perform well: area() is very slow and 
integrate() does not converge. Are in R other functions for numerical 
integration of one dimentional functions?

Thanks in advance 


Tiscali.Fax: il tuo fax online in promo fino al 31 dicembre, 
paghi 15€ e ricarichi 20€ 

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list