The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.
On top of being difficult to debug, in the last problem we ended up switching to the ODE integrator to solve the problem. It is entirely possible to ODE integrator is just returning the wrong integral, but debugging the two functions via expose_stan_functions suggests it's doing okay. Anyway, switching to the ODE integrator seems like the wrong thing. In the second thread the person implemented their own custom trapezoid quadrature.
Hopefully this is resolved by the temporary fix in #2183. The follow up issue to this is #2193 (once there's a fix in boost the #2183 patch can be reversed).
Description
A few questions have come up on the forums lately regarding integrate_1d where the integrator fails and it is difficult to debug what is going on.
Specifically I am talking about:
https://discourse.mc-stan.org/t/compilation-error-on-rstan/17972/
https://discourse.mc-stan.org/t/integrate-1d-errors-in-stan/17975/9
and
On top of being difficult to debug, in the last problem we ended up switching to the ODE integrator to solve the problem. It is entirely possible to ODE integrator is just returning the wrong integral, but debugging the two functions via
expose_stan_functions
suggests it's doing okay. Anyway, switching to the ODE integrator seems like the wrong thing. In the second thread the person implemented their own custom trapezoid quadrature.I think the double exponential quadrature we're using is just a bit fragile with combined with reverse mode autodiff. The Boost docs warn about how aggressive these methods are about evaluating functions at endpoints (where numerics blow up): https://www.boost.org/doc/libs/1_74_0/libs/math/doc/html/math_toolkit/double_exponential/de_caveats.html
At this point we need some switches for people to press so they can figure out how to get their quadratures working. Maybe:
Enabling other quadrature techniques (Boost's trapezoid quadrature in particular)
Making it easier to control error in integrals, either by doing a fix number of integration steps or just making it easier to adjust the tolerances
Current Version:
v3.3.0