SciML / SciMLExpectations.jl

Fast uncertainty quantification for scientific machine learning (SciML) and differential equations
https://docs.sciml.ai/SciMLExpectations/stable/
Other
65 stars 20 forks source link

What is the difference between `using IntegralCubature` and `using Integrals, Cubature` in the example? #152

Closed homocomputeris closed 7 months ago

homocomputeris commented 7 months ago

Question❓

Slightly modified example from the readme

using SciMLExpectations, OrdinaryDiffEq, Distributions, Integrals, Cubature

function eom!(du, u, p, t, A)
    du .= A * u
end

u0 = [1.0, 1.0]
tspan = (0.0, 3.0)
p = [1.0; 2.0]
A = [0.0 1.0; -p[1] -p[2]]
prob = ODEProblem((du, u, p, t) -> eom!(du, u, p, t, A), u0, tspan, p)
u0s_dist = (Uniform(1, 10), truncated(Normal(3.0, 1), 0.0, 6.0))
gd = GenericDistribution(u0s_dist...)
cov(x, u, p) = x, p

sm = SystemMap(prob, Tsit5(), save_everystep = false)

analytical = (exp(A * tspan[end]) * [mean(d) for d in u0s_dist])
analytical

g(sol, p) = sol[:, end]
exprob = ExpectationProblem(sm, g, cov, gd; nout = length(u0))
sol = solve(exprob, Koopman(); quadalg = CubatureJLh(),
            ireltol = 1e-3, iabstol = 1e-3)
sol.u # Expectation of the states 1 and 2 at the final time point

fails with

ERROR: UndefVarError: `CubatureJLh` not defined
Stacktrace:
 [1] top-level scope
   @ ~/test/test.jl:25

Integrals.jl docs say

CubatureJLh: h-Cubature from Cubature.jl. Requires using Cubature.

So, shouldn't SciMLExpectations.jl work with using Integrals, Cubature too? Or is there significant difference in the scope of application of those packages?

ChrisRackauckas commented 7 months ago

using IntegralCubature is the old way that was deprecated. It was removed when Julia v1.9 came out as package extensions gave an easier way to make the solver addons that would stay up to date. If you do this old way, then you'll have issues with your environment because its compats are really old. This repo needs to be updated, see https://github.com/SciML/SciMLExpectations.jl/pull/148