ndeutschmann / zunis

Normalizing flows for neural importance sampling
https://zunis.readthedocs.io
MIT License
32 stars 6 forks source link

Integration in R^d #12

Closed YazidJanati closed 3 years ago

YazidJanati commented 3 years ago

Hi!

How can this be used for general integration problems? It seems that this is limited to integration over the hypercube.

What if i want to estimate normalizing constants of densities supported in R^d?

Thank you in advance.

ndeutschmann commented 3 years ago

Hi Yazid,

If you are integrating over R^d, you can always map back to the unit hypercube by a change of variables that maps [0,1] to R. For example, you could use

image

But any bijective function that has two divergences might be suitable (arctanh would work too for example). There are still necessary conditions for such integrals to converge (with this approach, x^2 f(x) needs to be integrable over R).

Note BTW that in practice this is how you would define sampling over all of R. The "naive" method of sampling uniformly over a large enough interval yields an estimator with infinite variance.

ndeutschmann commented 3 years ago

NB: I think it would be a good idea to include a function wrapper to do this automatically in zunis.utils.function_wrapper, which already has tools to remap arbitrary intervals to the unit hypercube. In the meantime I would advise you to just implement a change of variable like the one above by hand.

YazidJanati commented 3 years ago

Thank you for your quick and useful answer.