[R] Fwd: Numerical integration
Hans W Borchers
hwborchers at googlemail.com
Thu Nov 18 07:06:23 CET 2010
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
More information about the R-help
mailing list