Re: [R] integration

From: Ravi Varadhan <rvaradhan_at_jhmi.edu>
Date: Tue, 18 Dec 2007 09:46:47 -0500

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.


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

Davide



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
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 18 Dec 2007 - 15:01:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 18 Dec 2007 - 15:30:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.