问题描述
我在寻找一个双积分的解决方案比
I'm looking for a solution for a double integral that is faster than
integrate(function(y) {
sapply(y, function(y) {
integrate(function(x) myfun(x,y), llim, ulim)$value
})
}, llim, ulim)
与如
myfun <- function(x,y) cos(x+y)
llim <- -0.5
ulim <- 0.5
我发现了一个<一个href=\"http://docs.lib.purdue.edu/cgi/viewcontent.cgi?article=1907&context=cstech&sei-redir=1&referer=http://www.google.be/url?sa=t&rct=j&q=quad2d&source=web&cd=4&ved=0CFEQFjAD&url=http%253A%252F%252Fdocs.lib.purdue.edu%252Fcgi%252Fviewcontent.cgi%253Farticle%253D1907%2526context%253Dcstech&ei=jvEWT6rcEYiL8gPjlJDzAg&usg=AFQjCNH_F8u0HdaVM0v6WpR0MmKM_sjeAA#search=%22quad2d%22\">old这被称为所谓的 quad2d
FORTRAN程序,但我无法找到任何东西,但对于MATLAB对其余一些帮助页纸。所以我在寻找一个C或FORTRAN库,可以做二重积分快(即不带sapply循环),并可以从R.被称为所有的想法都非常AP preciated,只要他们是所有GPL兼容。
I found an old paper that referred to a FORTRAN program called quad2d
, but I couldn't find anything else but some help pages for matlab for the rest. So I'm looking for a C or FORTRAN library that can do double integrals quick (i.e. without the sapply loop), and that can be called from R. All ideas are very much appreciated, as long as they're all GPL compatible.
如果该解决方案包括呼叫从那些已经随R中的库等功能,我很乐意向他们听到的为好。
If the solution involves calling other functions from the libraries that are already shipped with R, I'd love to hear from them as well.
推荐答案
包的确利用自适应算法2D(和Nd)的集成。它应该超越于大多数积简单的方法。
The cubature package does 2D (and N-D) integration using an adaptive algorithm. It should outperform simpler approaches for most integrands.
这篇关于R中快速计算二重积分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!