Eduardo de Oliveira Horta <eduardo.oliveirahorta <at> gmail.com> writes:

> 
> ---------- Forwarded message ----------
> From: Eduardo de Oliveira Horta <eduardo.oliveirahorta <at> gmail.com>
> Date: Wed, Nov 17, 2010 at 3:59 PM
> Subject: Re: [R] Numerical integration
> To: David Winsemius <dwinsemius <at> comcast.net>
> 
> It works, however is not very efficient for the problem I'm working with,
> since it is the same as vectorizing the integrand before applying
> "integrate".
> 
> Any other thoughts? Efficiency would be highly welcome!
> 
> Thanks again,
> 
> Eduardo Horta
> 

'adaptIntegrate' in package "cubature" does not require pre-vectorized 
functions. But I doubt it is more efficient as every integration needs
to perform a lot of function calls.

And with 'adaptIntegrate' you have to do the reduction of an infinite
interval to a finite one yourself. E. g., with a given function f define

    g <- function(x) f(1/x) / x^2
    adaptIntegrate(g, 0, 1/a)      # instead of integrate(f, a, Inf)

You have not given the slightest indication why your function integration
would be so slow. So it's difficult to give more focussed advice.

Hans Werner

______________________________________________
R-help@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.

Reply via email to