JuliaMath / HCubature.jl

pure-Julia multidimensional h-adaptive integration
Other
153 stars 25 forks source link

Automatic support for infinite domains #12

Open IljaK91 opened 5 years ago

IljaK91 commented 5 years ago

I would like to integrate a two-dimensional function from -Inf to Inf. To explore my possiblities, I wrote this simple function

f(x) = x.^2 .*pdf.(Normal(), 2 .*x)

It works without problems when using QuadGK, but does not converge at all using HCubature:

using QuadGK, Distributions, HCubature

f(x) = x.^2 .*pdf.(Normal(), 2 .*x)
quadgk(f, -Inf, Inf)
hcubature(f, [-Inf], [Inf] )

Is this a well known problem?

stevengj commented 5 years ago

The QuadGK package automatically transforms infinite intervals to finite ones with a change of variables. Most integration packages do not do this for you — you have to change variables yourself, e.g. as described here.

It would be a nice feature to do this automatically in HCubature, however.

IljaK91 commented 5 years ago

Maybe I can have a look during the winter break. It doesn't sound too complicated and it seems that copying the relevant code from QuadGK should be sufficient.