Closed mmikhasenko closed 4 years ago
I haven't really updated the package in a long time. Let me try to bring it up to date, shouldn't be too hard.
You should be able to download the package now.
Notice however that NIntegration has only been written to work with functions with domain in ℝ³ (I should really make the API more general). To get your example in https://github.com/giordano/Cuba.jl/issues/28#issuecomment-643221588 working, you need to run it like this:
using ForwardDiff
using NIntegration
b(cosθ, ϕ, c) = c[1] * cosθ * sin(ϕ) + c[2] * cosθ^2 * cos(ϕ)^2
f(c) = nintegrate((x, y, z) -> b(x, y, c), (-1.0, -π, 0.0), (1.0, π, 1.0))[1]
ForwardDiff.gradient(f, [1.1, 1.1])
P.S. I don't know if this would give sensible results, but seems to work.
thanks a lot for checking and updating! It works now, even the automatic differentiation that is super cool.
It is faster even than the other pure-julia package HCubature
, but significantly slower than c++ Cuba.
I benchmark it against other routines:
Cuba.cuhre ~ 1.3s
HCubature ~ 30s
NIntegration ~ 13s
I will try to publish my benchmark example that anyone can run it. Perhaps, it might give some hints for further optimization.
Thanks again. The issue can be closed
As far as I know Cuba uses a different strategy than HCubature and NIntegration to subdivide the regions, which might be making it faster here. I have thought on improving the strategy used here but have never gotten to do it (and unfortunately right now I cannot make any promises to work on it soon).
no problem, thanks for the replies.
I used Cuba.cuhre
. That is what I found about the algorithm (the description does look similar to yours):
Cuhre Implementation in CUBA
• Deterministic algorithm (uses Genz–Malik cubature rules
of polynomial degree).
• Variance reduction: Globally adaptive subdivision.
• Algorithm: Until the requested accuracy is reached, bisect the region with the largest error along the axis with the largest fourth difference.
• Consistent interface only, same as original DCUHRE
(TOMS Algorithm 698).
Of course, there is also some performance left out of the table as the current algorithm is doing unnecessary extra work for your example that is two dimensional (I'll try to generalize it sooner than later).
The point of Steven over discourse is also important, you would have to compare with the same target accuracy.
I would love to try the package, as neither
QuadGK
, norCubature
fits my needs entirely. https://github.com/giordano/Cuba.jl/issues/28#issuecomment-643221588any suggestions, how to fix the installation? Thanks in advance