ranjanan / MonteCarloIntegration.jl

A package for multi-dimensional integration using monte carlo methods
MIT License
37 stars 17 forks source link

Bounds error #22

Open timholy opened 9 months ago

timholy commented 9 months ago
julia> νs = 10 .^ (range(-3, stop=3, length=15))
       pmorph(x, ν) = (r² = x'*x; exp(-r²^ν/(2ν)))
       pmorph_x1_2(x, ν) = (r² = x'*x; x[1]^2 * exp(-r²^ν/(2ν)))
       d = 2
       rstart = fill(-5, d)
       rstop  = -rstart
       I0 = [vegas(x -> pmorph(x, ν), rstart, rstop) for ν in νs]
ERROR: BoundsError: attempt to access 1000×2 Matrix{Float64} at index [0, 1]
Stacktrace:
 [1] getindex
   @ .\essentials.jl:14 [inlined]
 [2] update_grid(x::Matrix{Float64}, delx::Matrix{Float64}, d::Matrix{Float64})
   @ MonteCarloIntegration C:\Users\timho\.julia\dev\MonteCarloIntegration\src\vegas.jl:235
 [3] vegas(func::var"#6#8"{…}, lb::Vector{…}, ub::Vector{…}; maxiter::Int64, nbins::Int64, ncalls::Int64, rtol::Float64, atol::Float64, debug::Bool, batch::Bool, alpha::Float64)        
   @ MonteCarloIntegration C:\Users\timho\.julia\dev\MonteCarloIntegration\src\vegas.jl:148
 [4] vegas(func::Function, lb::Vector{Int64}, ub::Vector{Int64})
   @ MonteCarloIntegration C:\Users\timho\.julia\dev\MonteCarloIntegration\src\vegas.jl:70
 [5] (::var"#5#7")(ν::Float64)
   @ Main .\none:0
 [6] iterate(::Base.Generator{Vector{Any}, DualNumbers.var"#1#3"})
   @ Base .\generator.jl:47 [inlined]
 [7] collect(itr::Base.Generator{Vector{Float64}, var"#5#7"})
   @ Base .\array.jl:834
 [8] top-level scope
   @ c:\Users\timho\OneDrive\Documents\publications\clustering\checks.jl:181
Some type information was truncated. Use `show(err)` to see complete types.

(That charcter is a \nu and not a v.)