https://github.com/sciml/scimlexpectations.jl
Fast uncertainty quantification for scientific machine learning (SciML) and differential equations
https://github.com/sciml/scimlexpectations.jl
differential-equations differentialequations integration julia ode scientific-machine-learning sciml uncertainty-quantification uq
Last synced: 28 days ago
JSON representation
Fast uncertainty quantification for scientific machine learning (SciML) and differential equations
- Host: GitHub
- URL: https://github.com/sciml/scimlexpectations.jl
- Owner: SciML
- License: other
- Created: 2016-11-02T18:17:13.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2025-08-18T21:15:44.000Z (about 2 months ago)
- Last Synced: 2025-09-05T09:55:07.028Z (about 1 month ago)
- Topics: differential-equations, differentialequations, integration, julia, ode, scientific-machine-learning, sciml, uncertainty-quantification, uq
- Language: Julia
- Homepage: https://docs.sciml.ai/SciMLExpectations/stable/
- Size: 70.1 MB
- Stars: 69
- Watchers: 7
- Forks: 20
- Open Issues: 34
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Citation: CITATION.bib
Awesome Lists containing this project
README
# SciMLExpectations.jl: Expectated Values of Simulations and Uncertainty Quantification
[](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
[](https://docs.sciml.ai/SciMLExpectations/stable/)[](https://codecov.io/gh/SciML/SciMLExpectations.jl)
[](https://github.com/SciML/SciMLExpectations.jl/actions?query=workflow%3ACI)[](https://github.com/SciML/ColPrac)
[](https://github.com/SciML/SciMLStyle)#### This package is still under heavy construction. Use at your own risk!
SciMLExpectations.jl is a package for quantifying the uncertainties of simulations by
calculating the expectations of observables with respect to input uncertainties. Its goal
is to make it fast and easy to compute solution moments in a differentiable way in order
to enable fast optimization under uncertainty.## Tutorials and Documentation
For information on using the package,
[see the stable documentation](https://docs.sciml.ai/SciMLExpectations/stable/). Use the
[in-development documentation](https://docs.sciml.ai/SciMLExpectations/dev/) for the version of
the documentation, which contains the unreleased features.### Example
```julia
using SciMLExpectations, OrdinaryDiffEq, Distributions, Cubaturefunction eom!(du, u, p, t, A)
du .= A * u
endu0 = [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, psm = SystemMap(prob, Tsit5(), save_everystep = false)
analytical = (exp(A * tspan[end]) * [mean(d) for d in u0s_dist])
analytical
``````
julia> analytical
2-element Vector{Float64}:
1.5433991194037804
-1.120209038276938
``````julia
g(sol, p) = sol[:, end]
exprob = ExpectationProblem(sm, g, cov, gd)
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
``````
2-element Vector{Float64}:
1.5433860531082695
-1.1201922503747408
```# Approximate error on the expectation
sol.resid
#=
2-element Vector{Float64}:
7.193424502016654e-5
5.2074632876847327e-5
=#```
```