Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic support for infinite domains #12

Open
IljaK91 opened this issue Nov 22, 2018 · 2 comments
Open

Automatic support for infinite domains #12

IljaK91 opened this issue Nov 22, 2018 · 2 comments

Comments

@IljaK91
Copy link

IljaK91 commented Nov 22, 2018

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
Copy link
Member

stevengj commented Nov 23, 2018

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.

@stevengj stevengj changed the title Problem with convergence for bounds with Inf? Automatic support for infinite domains Nov 23, 2018
@IljaK91
Copy link
Author

IljaK91 commented Nov 26, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants