Cuba.jl
Cuba.jl copied to clipboard
Request: better user interface for integration over a non-unit cube
I think the interface would be much more intuitive if the users can directly specify the integration range, e.g. cuhre(f::Function, xmin, xmax), similar as the interface in Cubature.jl
While I agree that it would be nice to have this feature, you should consider that Cubature
library works with arbitrary bounds, but Cuba
doesn't (see http://www.feynarts.de/cuba/). This is why the Julia wrappers Cubature.jl
and Cuba.jl
behave differently in this regard: Cubature.jl
simply passes the xmin
and xmax
arguments to the library functions, instead Cuba.jl
should first rearrange the integrand function (and I don't think it's feasible).
I won't try to address this problem, but I'll leave this issue open just in case someone will come up with a simple and elegant solution.
One possibility for users is to use this package (not yet registered, though): https://github.com/tpapp/ContinuousTransformations.jl Following the example in the README.md, with this code you can compute the integral of a Gaussian-like function over the infinite domain (0, Inf), without having to write down the explicit transformation:
julia> using Cuba, ContinuousTransformations
julia> f, dom = integral_substitution(INVODDSRATIO, x->exp(-x^2), 0..Inf)
(ContinuousTransformations.#27, (0.0..1.0))
julia> cuhre((x,y) -> y[1] = f(x[1]))[1][1] ≈ sqrt(pi)/2
true