Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compute a high dimensional multiple integral with infinite bounds using vegas in Julia

Tags:

julia

I am trying to compute a high dimensional integral using Julia (>1400 dimensions). I am thus trying to do this using the function vegas, as it can presumably compute high dimensional integrals. However, vegas assumes that the domain of integration is [0,1]^n but my integral is over R^n. The documentation of vegas suggests a change of variables, but I cannot get it to work in multiple dimensions.

So, if I type in Julia the following integral in 2 dimensions:

using LinearAlgebra, Cuba
multinormal(x,μ,Σ) = det(2*π*Σ)^(-1/2)*exp(-1/2*(x-μ)'*inv(Σ)*(x-μ))
vegas((x,f)->f=multinormal(x,[0;0],[1 0;0 1]),2)

I get the result

Component:
 1: 0.0 ± 7.025180405943273e-18 (prob.: -999.0)
Integrand evaluations: 1000
Number of subregions:  0
Note: The desired accuracy was reached

which assumes that the integral is over [0,1]^2.

Trying to compute the same integral over [0,infinity)^2, I tried the change of variables suggested here as

vegas((x,f)->f=multinormal(x./(1 .- x),[0;0],[1 0;0 1])./(1 .-x).^2,2)

which gives me the result

Component:
 1: 0.0 ± 7.025180405943273e-18 (prob.: -999.0)
Integrand evaluations: 1000
Number of subregions:  0
Note: The desired accuracy was reached

But the result should be 0.5 rather than 0.

How could I compute this integral of the multivariate normal distribution with infinite integration limits using vegas?

like image 960
Mauricio Avatar asked Oct 25 '25 02:10

Mauricio


1 Answers

If you use Quadrature.jl it'll perform the necessary changes of variables for you automatically. Then you just use [-Inf,Inf] bounds. See examples in the tests:

https://github.com/SciML/Quadrature.jl/blob/master/test/inf_integral_tests.jl

like image 61
Chris Rackauckas Avatar answered Oct 27 '25 01:10

Chris Rackauckas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!