Cuba.jl icon indicating copy to clipboard operation
Cuba.jl copied to clipboard

Request: better user interface for integration over a non-unit cube

Open xiaoweiz opened this issue 7 years ago • 2 comments

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

xiaoweiz avatar Mar 06 '17 06:03 xiaoweiz

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.

giordano avatar Mar 06 '17 08:03 giordano

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

giordano avatar Mar 31 '17 10:03 giordano