giordano / Cuba.jl

Library for multidimensional numerical integration with four independent algorithms: Vegas, Suave, Divonne, and Cuhre.
https://giordano.github.io/Cuba.jl/stable
MIT License
75 stars 9 forks source link

Regions -> True inside Cuba.jl? #13

Open improbable-22 opened 7 years ago

improbable-22 commented 7 years ago

In the Mathematica interface to Cuba, I can obtain a list of the regions used by option Regions -> True. Is there any way to get this information in Julia?

After skimming the web page, it's unclear to me whether the C++ library exports this data, so perhaps this cannot be done.

giordano commented 7 years ago

I don't think this feature is exposed by the C library in the same way it is in Mathematica. A possibility is to use verbosity, this prints to screen many additional information including the list of subregions (but this is lee handy than what you're asking for). For example:

julia> cuhre((x, f) -> f[1] = cos(x[1]), flags = 3)
Cuhre input parameters:
  ndim 2
  ncomp 1
  nvec 1
  epsrel 0.0001
  epsabs 1e-12
  flags 3
  mineval 0
  maxeval 1000000
  key 0
  statefile ""

Region (0.000000) - (1.000000)
       (0.000000) - (1.000000)
[1] 0.841471 +- 2.22045e-16

Iteration 1:  65 integrand evaluations so far
[1] 0.841471 +- 2.22045e-16     chisq 0 (0 df)

Region (0.000000) - (0.500000)
       (0.000000) - (1.000000)
[1] 0.479426 +- 1.56691e-12

Region (0.500000) - (1.000000)
       (0.000000) - (1.000000)
[1] 0.362045 +- 1.1831e-12

Iteration 2:  195 integrand evaluations so far
[1] 0.841471 +- 2.22045e-16     chisq 1.86265e-09 (1 df)
Component:
 1: 0.8414709848078966 ± 2.2204460420128823e-16 (prob.: 3.443539937576958e-5)
Integrand evaluations: 195
Fail:                  0
Number of subregions:  2
improbable-22 commented 7 years ago

Thanks, I would not have thought of that.

Will experiment a bit...

giordano commented 7 years ago

In addition, Cuba library comes with a tool called partview which allows visualizing the tessellation. You can run a Julia script with verbosity = 3 from the command line and pipe the output to partview.