calculating double integrals in R quickly

杀马特。学长 韩版系。学妹 提交于 2019-11-27 01:36:52

The cubature package does 2D (and N-D) integration using an adaptive algorithm. It should outperform simpler approaches for most integrands.

The pracma package that Joshua pointed out contains a version of quad2d.

quad2d(myfun, llim, ulim, llim, ulim)

This gives the same answer, within numerical tolerance, as your loop, using the example function.

By default, with your example function, quad2d is slower than the loop. If you drop n down, you can make it faster, but I guess it depends upon how smooth your function is, and how much accuracy you are willing to sacrifice for speed.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!