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?
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.
Hi Ravi, are you saying to apply the idea of a trapezoidal method "again", because I was expecting the integrate() already do it for me. Is not the case? I am also dealing with troubles related to integrate. Just to say, I tried to figure out the problem in Mathematica and it gives me the expected/correct solution. I am integrating a function with shape like a exp(x), x>0. The value of the function get lower when x is big but integrate return zero. If some one can give a suggestion, it will be very appreciated. -- View this message in context: http://r.789695.n4.nabble.com/integration-tp843252p3771660.html Sent from the R help mailing list archive at Nabble.com.
On 26.08.2011 20:27, . wrote:> Hi Ravi, > > are you saying to apply the idea of a trapezoidal method "again", because I > was expecting the integrate() already do it for me. Is not the case? > > I am also dealing with troubles related to integrate. Just to say, I tried > to figure out the problem in Mathematica and it gives me the > expected/correct solution. > > I am integrating a function with shape like a exp(x), x>0. The value of the > function get lower when x is big but integrate return zero. > > If some one can give a suggestion, it will be very appreciated. > > -- > View this message in context: http://r.789695.n4.nabble.com/integration-tp843252p3771660.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.So you never read the posting guide, ".", did you? Please do so! Please specify reproducible examples! Please quote the original messages from the thread you are replying to. Note this is a mailing list you are obviously misusing via Nabble. If you want to contact Ravi, write also to Ravi and not only to the mailing list R-help! Uwe Ligges