From 716dbda95771ae6b233521a3503e256aa9b7468e Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Fri, 23 Feb 2024 21:10:21 +0000 Subject: [PATCH] build based on 0568c4a --- previews/PR305/.documenter-siteinfo.json | 2 +- .../PR305/benchmarks/hodgkinhuxley/index.html | 2 +- .../PR305/benchmarks/lotkavolterra/index.html | 2 +- .../multi-language-wrappers/index.html | 2 +- previews/PR305/benchmarks/orego/index.html | 2 +- previews/PR305/benchmarks/pleiades/index.html | 2 +- previews/PR305/benchmarks/rober/index.html | 2 +- .../PR305/benchmarks/vanderpol/index.html | 2 +- previews/PR305/diffusions/index.html | 2 +- previews/PR305/filtering/index.html | 14 +- previews/PR305/implementation/index.html | 2 +- previews/PR305/index.html | 2 +- previews/PR305/initialization/index.html | 2 +- previews/PR305/likelihoods/index.html | 4 +- previews/PR305/priors/150cadea.svg | 174 +++++++++++++++++ previews/PR305/priors/237eeb04.svg | 174 +++++++++++++++++ previews/PR305/priors/312d20ed.svg | 176 +++++++++++++++++ previews/PR305/priors/32064959.svg | 174 ----------------- previews/PR305/priors/334f9da8.svg | 176 ----------------- previews/PR305/priors/3ebe146d.svg | 102 ---------- previews/PR305/priors/9c27750f.svg | 182 ++++++++++++++++++ previews/PR305/priors/9d2e0944.svg | 182 ------------------ previews/PR305/priors/a1a57975.svg | 174 ----------------- previews/PR305/priors/eb04fb46.svg | 104 ++++++++++ previews/PR305/priors/index.html | 20 +- previews/PR305/references/index.html | 2 +- previews/PR305/solvers/index.html | 8 +- .../dae/{92d6b6f6.svg => acdff63c.svg} | 90 ++++----- .../dae/{f900dfcf.svg => b8457e2f.svg} | 134 ++++++------- previews/PR305/tutorials/dae/index.html | 6 +- .../{040b01ee.svg => 35d9e954.svg} | 64 +++--- .../{9ea1717f.svg => 55e751ef.svg} | 64 +++--- .../{b71f2d85.svg => 7334cb06.svg} | 72 +++---- .../{6ea3b8f2.svg => d117fca1.svg} | 76 ++++---- .../PR305/tutorials/dynamical_odes/index.html | 8 +- .../{272f6aaa.svg => 334d650f.svg} | 98 +++++----- .../{80e2fab0.svg => 8c59d23e.svg} | 102 +++++----- .../{468a6f1b.svg => 9f557e9c.svg} | 82 ++++---- .../{2c906e49.svg => d4bf17d7.svg} | 74 +++---- .../exponential_integrators/index.html | 8 +- .../{19a76b72.svg => 9c4d2956.svg} | 80 ++++---- .../{949a7f59.svg => 9da6d436.svg} | 72 +++---- .../{0c05c7cd.svg => c0dbcbaa.svg} | 72 +++---- .../tutorials/getting_started/index.html | 8 +- .../ode_parameter_inference/1921a277.svg | 92 +++++++++ .../ode_parameter_inference/45aa2674.svg | 87 +++++++++ .../ode_parameter_inference/49c9d55f.svg | 92 +++++++++ .../ode_parameter_inference/6a824939.svg | 87 --------- .../ode_parameter_inference/739bac36.svg | 92 --------- .../ode_parameter_inference/e794f0c2.svg | 92 --------- .../ode_parameter_inference/index.html | 14 +- 51 files changed, 1679 insertions(+), 1677 deletions(-) create mode 100644 previews/PR305/priors/150cadea.svg create mode 100644 previews/PR305/priors/237eeb04.svg create mode 100644 previews/PR305/priors/312d20ed.svg delete mode 100644 previews/PR305/priors/32064959.svg delete mode 100644 previews/PR305/priors/334f9da8.svg delete mode 100644 previews/PR305/priors/3ebe146d.svg create mode 100644 previews/PR305/priors/9c27750f.svg delete mode 100644 previews/PR305/priors/9d2e0944.svg delete mode 100644 previews/PR305/priors/a1a57975.svg create mode 100644 previews/PR305/priors/eb04fb46.svg rename previews/PR305/tutorials/dae/{92d6b6f6.svg => acdff63c.svg} (99%) rename previews/PR305/tutorials/dae/{f900dfcf.svg => b8457e2f.svg} (99%) rename previews/PR305/tutorials/dynamical_odes/{040b01ee.svg => 35d9e954.svg} (97%) rename previews/PR305/tutorials/dynamical_odes/{9ea1717f.svg => 55e751ef.svg} (98%) rename previews/PR305/tutorials/dynamical_odes/{b71f2d85.svg => 7334cb06.svg} (98%) rename previews/PR305/tutorials/dynamical_odes/{6ea3b8f2.svg => d117fca1.svg} (99%) rename previews/PR305/tutorials/exponential_integrators/{272f6aaa.svg => 334d650f.svg} (98%) rename previews/PR305/tutorials/exponential_integrators/{80e2fab0.svg => 8c59d23e.svg} (98%) rename previews/PR305/tutorials/exponential_integrators/{468a6f1b.svg => 9f557e9c.svg} (99%) rename previews/PR305/tutorials/exponential_integrators/{2c906e49.svg => d4bf17d7.svg} (99%) rename previews/PR305/tutorials/getting_started/{19a76b72.svg => 9c4d2956.svg} (91%) rename previews/PR305/tutorials/getting_started/{949a7f59.svg => 9da6d436.svg} (98%) rename previews/PR305/tutorials/getting_started/{0c05c7cd.svg => c0dbcbaa.svg} (98%) create mode 100644 previews/PR305/tutorials/ode_parameter_inference/1921a277.svg create mode 100644 previews/PR305/tutorials/ode_parameter_inference/45aa2674.svg create mode 100644 previews/PR305/tutorials/ode_parameter_inference/49c9d55f.svg delete mode 100644 previews/PR305/tutorials/ode_parameter_inference/6a824939.svg delete mode 100644 previews/PR305/tutorials/ode_parameter_inference/739bac36.svg delete mode 100644 previews/PR305/tutorials/ode_parameter_inference/e794f0c2.svg diff --git a/previews/PR305/.documenter-siteinfo.json b/previews/PR305/.documenter-siteinfo.json index 1ee2746e3..84a7dfae4 100644 --- a/previews/PR305/.documenter-siteinfo.json +++ b/previews/PR305/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.1","generation_timestamp":"2024-02-23T20:34:52","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.1","generation_timestamp":"2024-02-23T21:10:00","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/previews/PR305/benchmarks/hodgkinhuxley/index.html b/previews/PR305/benchmarks/hodgkinhuxley/index.html index b3501cc1b..16c80d5fa 100644 --- a/previews/PR305/benchmarks/hodgkinhuxley/index.html +++ b/previews/PR305/benchmarks/hodgkinhuxley/index.html @@ -653,4 +653,4 @@ [8e850b90] libblastrampoline_jll v5.8.0+1 [8e850ede] nghttp2_jll v1.52.0+1 [3f19e933] p7zip_jll v17.4.0+2 -Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` +Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` diff --git a/previews/PR305/benchmarks/lotkavolterra/index.html b/previews/PR305/benchmarks/lotkavolterra/index.html index 84427f77e..e69dc6139 100644 --- a/previews/PR305/benchmarks/lotkavolterra/index.html +++ b/previews/PR305/benchmarks/lotkavolterra/index.html @@ -748,4 +748,4 @@ [8e850b90] libblastrampoline_jll v5.8.0+1 [8e850ede] nghttp2_jll v1.52.0+1 [3f19e933] p7zip_jll v17.4.0+2 -Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` +Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` diff --git a/previews/PR305/benchmarks/multi-language-wrappers/index.html b/previews/PR305/benchmarks/multi-language-wrappers/index.html index d9d600a23..225690813 100644 --- a/previews/PR305/benchmarks/multi-language-wrappers/index.html +++ b/previews/PR305/benchmarks/multi-language-wrappers/index.html @@ -692,4 +692,4 @@ [8e850b90] libblastrampoline_jll v5.8.0+1 [8e850ede] nghttp2_jll v1.52.0+1 [3f19e933] p7zip_jll v17.4.0+2 -Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` +Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` diff --git a/previews/PR305/benchmarks/orego/index.html b/previews/PR305/benchmarks/orego/index.html index 60aa84f80..f3b765b85 100644 --- a/previews/PR305/benchmarks/orego/index.html +++ b/previews/PR305/benchmarks/orego/index.html @@ -521,4 +521,4 @@ [8e850b90] libblastrampoline_jll v5.8.0+1 [8e850ede] nghttp2_jll v1.52.0+1 [3f19e933] p7zip_jll v17.4.0+2 -Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` +Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` diff --git a/previews/PR305/benchmarks/pleiades/index.html b/previews/PR305/benchmarks/pleiades/index.html index 70f80d828..42fd06478 100644 --- a/previews/PR305/benchmarks/pleiades/index.html +++ b/previews/PR305/benchmarks/pleiades/index.html @@ -564,4 +564,4 @@ [8e850b90] libblastrampoline_jll v5.8.0+1 [8e850ede] nghttp2_jll v1.52.0+1 [3f19e933] p7zip_jll v17.4.0+2 -Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` +Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` diff --git a/previews/PR305/benchmarks/rober/index.html b/previews/PR305/benchmarks/rober/index.html index 00400a330..989c83bae 100644 --- a/previews/PR305/benchmarks/rober/index.html +++ b/previews/PR305/benchmarks/rober/index.html @@ -517,4 +517,4 @@ [8e850b90] libblastrampoline_jll v5.8.0+1 [8e850ede] nghttp2_jll v1.52.0+1 [3f19e933] p7zip_jll v17.4.0+2 -Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` +Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` diff --git a/previews/PR305/benchmarks/vanderpol/index.html b/previews/PR305/benchmarks/vanderpol/index.html index a1295a591..442c9d796 100644 --- a/previews/PR305/benchmarks/vanderpol/index.html +++ b/previews/PR305/benchmarks/vanderpol/index.html @@ -658,4 +658,4 @@ [8e850b90] libblastrampoline_jll v5.8.0+1 [8e850ede] nghttp2_jll v1.52.0+1 [3f19e933] p7zip_jll v17.4.0+2 -Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` +Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m` diff --git a/previews/PR305/diffusions/index.html b/previews/PR305/diffusions/index.html index c91829912..c16985db5 100644 --- a/previews/PR305/diffusions/index.html +++ b/previews/PR305/diffusions/index.html @@ -5,4 +5,4 @@ \text{d} Y^{(i)}(t) &= Y^{(i+1)}(t) \ \text{d}t, \qquad i = 0, \dots, q-1, \\ \text{d} Y^{(q)}(t) &= \textcolor{#389826}{A} Y(t) \ \text{d}t + \textcolor{#4063D8}{\Gamma} \ \text{d}W(t), \\ Y(0) &\sim \textcolor{purple}{ \mathcal{N} \left( \mu_0, \Sigma_0 \right) }. -\end{aligned}\]

Then $Y^{(i)}(t)$ models the $i$-th derivative of $y(t)$. In this section, we consider choices relating to the "diffusion" $\textcolor{#4063D8}{\Gamma}$. If you're more interested in the drift matrix $\textcolor{#389826}{A}$ check out the Priors section, and for info on the initial distribution $\textcolor{purple}{ \mathcal{N} \left( \mu_0, \Sigma_0 \right) }$ check out the Initialization section.

Diffusion and calibration

We call $\textcolor{#4063D8}{\Gamma}$ the "diffusion" parameter. Since it is typically not known we need to estimate it; this is called "calibration".

ProbNumDiffEq.jl provides a few different choices for how to model and estimate $\textcolor{#4063D8}{\Gamma}$:

Or more compactly:

Isotropic:Diagonal (only for the EK0)
Time-varyingDynamicDiffusionDynamicMVDiffusion
Time-fixedFixedDiffusionFixedMVDiffusion

For more details on diffusions and calibration, check out this paper [9].

API

ProbNumDiffEq.DynamicDiffusionType
DynamicDiffusion()

Time-varying, isotropic diffusion, which is quasi-maximum-likelihood-estimated at each step.

This is the recommended diffusion when using adaptive step-size selection, and in particular also when solving stiff systems.

source
ProbNumDiffEq.FixedDiffusionType
FixedDiffusion(; initial_diffusion=1.0, calibrate=true)

Time-fixed, isotropic diffusion, which is (optionally) quasi-maximum-likelihood-estimated.

This is the recommended diffusion when using fixed steps.

By default with calibrate=true, all covariances are re-scaled at the end of the solve with the MLE diffusion. Set calibrate=false to skip this step, e.g. when setting the initial_diffusion and then estimating the diffusion outside of the solver (e.g. with Fenrir.jl).

source
ProbNumDiffEq.DynamicMVDiffusionType
DynamicMVDiffusion()

Time-varying, diagonal diffusion, which is quasi-maximum-likelihood-estimated at each step.

Only works with the EK0!

A multi-variate version of DynamicDiffusion, where instead of an isotropic matrix, a diagonal matrix is estimated. This can be helpful to get more expressive posterior covariances when using the EK0, since the individual dimensions can be adjusted separately.

References

  • [9] Bosch et al, "Calibrated Adaptive Probabilistic ODE Solvers", AISTATS (2021)
source
ProbNumDiffEq.FixedMVDiffusionType
FixedMVDiffusion(; initial_diffusion=1.0, calibrate=true)

Time-fixed, diagonal diffusion, which is quasi-maximum-likelihood-estimated at each step.

Only works with the EK0!

A multi-variate version of FixedDiffusion, where instead of an isotropic matrix, a diagonal matrix is estimated. This can be helpful to get more expressive posterior covariances when using the EK0, since the individual dimensions can be adjusted separately.

References

  • [9] Bosch et al, "Calibrated Adaptive Probabilistic ODE Solvers", AISTATS (2021)
source

References

[9]
N. Bosch, P. Hennig and F. Tronarp. Calibrated Adaptive Probabilistic ODE Solvers. In: Proceedings of The 24th International Conference on Artificial Intelligence and Statistics, Vol. 130 of Proceedings of Machine Learning Research, edited by A. Banerjee and K. Fukumizu (PMLR, 13–15 Apr 2021); pp. 3466–3474.
+\end{aligned}\]

Then $Y^{(i)}(t)$ models the $i$-th derivative of $y(t)$. In this section, we consider choices relating to the "diffusion" $\textcolor{#4063D8}{\Gamma}$. If you're more interested in the drift matrix $\textcolor{#389826}{A}$ check out the Priors section, and for info on the initial distribution $\textcolor{purple}{ \mathcal{N} \left( \mu_0, \Sigma_0 \right) }$ check out the Initialization section.

Diffusion and calibration

We call $\textcolor{#4063D8}{\Gamma}$ the "diffusion" parameter. Since it is typically not known we need to estimate it; this is called "calibration".

ProbNumDiffEq.jl provides a few different choices for how to model and estimate $\textcolor{#4063D8}{\Gamma}$:

Or more compactly:

Isotropic:Diagonal (only for the EK0)
Time-varyingDynamicDiffusionDynamicMVDiffusion
Time-fixedFixedDiffusionFixedMVDiffusion

For more details on diffusions and calibration, check out this paper [9].

API

ProbNumDiffEq.DynamicDiffusionType
DynamicDiffusion()

Time-varying, isotropic diffusion, which is quasi-maximum-likelihood-estimated at each step.

This is the recommended diffusion when using adaptive step-size selection, and in particular also when solving stiff systems.

source
ProbNumDiffEq.FixedDiffusionType
FixedDiffusion(; initial_diffusion=1.0, calibrate=true)

Time-fixed, isotropic diffusion, which is (optionally) quasi-maximum-likelihood-estimated.

This is the recommended diffusion when using fixed steps.

By default with calibrate=true, all covariances are re-scaled at the end of the solve with the MLE diffusion. Set calibrate=false to skip this step, e.g. when setting the initial_diffusion and then estimating the diffusion outside of the solver (e.g. with Fenrir.jl).

source
ProbNumDiffEq.DynamicMVDiffusionType
DynamicMVDiffusion()

Time-varying, diagonal diffusion, which is quasi-maximum-likelihood-estimated at each step.

Only works with the EK0!

A multi-variate version of DynamicDiffusion, where instead of an isotropic matrix, a diagonal matrix is estimated. This can be helpful to get more expressive posterior covariances when using the EK0, since the individual dimensions can be adjusted separately.

References

  • [9] Bosch et al, "Calibrated Adaptive Probabilistic ODE Solvers", AISTATS (2021)
source
ProbNumDiffEq.FixedMVDiffusionType
FixedMVDiffusion(; initial_diffusion=1.0, calibrate=true)

Time-fixed, diagonal diffusion, which is quasi-maximum-likelihood-estimated at each step.

Only works with the EK0!

A multi-variate version of FixedDiffusion, where instead of an isotropic matrix, a diagonal matrix is estimated. This can be helpful to get more expressive posterior covariances when using the EK0, since the individual dimensions can be adjusted separately.

References

  • [9] Bosch et al, "Calibrated Adaptive Probabilistic ODE Solvers", AISTATS (2021)
source

References

[9]
N. Bosch, P. Hennig and F. Tronarp. Calibrated Adaptive Probabilistic ODE Solvers. In: Proceedings of The 24th International Conference on Artificial Intelligence and Statistics, Vol. 130 of Proceedings of Machine Learning Research, edited by A. Banerjee and K. Fukumizu (PMLR, 13–15 Apr 2021); pp. 3466–3474.
diff --git a/previews/PR305/filtering/index.html b/previews/PR305/filtering/index.html index 95f84ced4..9a64a85f8 100644 --- a/previews/PR305/filtering/index.html +++ b/previews/PR305/filtering/index.html @@ -1,26 +1,26 @@ -Filtering and Smoothing · ProbNumDiffEq.jl

Gaussian Filtering and Smoothing

Predict

ProbNumDiffEq.predictFunction
predict(x::Gaussian, A::AbstractMatrix, Q::AbstractMatrix)

Prediction step in Kalman filtering for linear dynamics models.

Given a Gaussian $x = \mathcal{N}(μ, Σ)$, compute and return $\mathcal{N}(A μ, A Σ A^T + Q)$.

See also the non-allocating square-root version predict!.

source
ProbNumDiffEq.predict!Function
predict!(x_out, x_curr, Ah, Qh, cachemat)

In-place and square-root implementation of predict which saves the result into x_out.

Only works with PSDMatrices.PSDMatrix types as Ah, Qh, and in the covariances of x_curr and x_out (both of type Gaussian). To prevent allocations, a cache matrix cachemat of size $D \times 2D$ (where $D \times D$ is the size of Ah and Qh) needs to be passed.

See also: predict.

source

Update

ProbNumDiffEq.updateFunction
update(x, measurement, H)

Update step in Kalman filtering for linear dynamics models.

Given a Gaussian $x = \mathcal{N}(μ, Σ)$ and a measurement $z = \mathcal{N}(\hat{z}, S)$, with $S = H Σ H^T$, compute

\[\begin{aligned} +Filtering and Smoothing · ProbNumDiffEq.jl

Gaussian Filtering and Smoothing

Predict

ProbNumDiffEq.predictFunction
predict(x::Gaussian, A::AbstractMatrix, Q::AbstractMatrix)

Prediction step in Kalman filtering for linear dynamics models.

Given a Gaussian $x = \mathcal{N}(μ, Σ)$, compute and return $\mathcal{N}(A μ, A Σ A^T + Q)$.

See also the non-allocating square-root version predict!.

source
ProbNumDiffEq.predict!Function
predict!(x_out, x_curr, Ah, Qh, cachemat)

In-place and square-root implementation of predict which saves the result into x_out.

Only works with PSDMatrices.PSDMatrix types as Ah, Qh, and in the covariances of x_curr and x_out (both of type Gaussian). To prevent allocations, a cache matrix cachemat of size $D \times 2D$ (where $D \times D$ is the size of Ah and Qh) needs to be passed.

See also: predict.

source

Update

ProbNumDiffEq.updateFunction
update(x, measurement, H)

Update step in Kalman filtering for linear dynamics models.

Given a Gaussian $x = \mathcal{N}(μ, Σ)$ and a measurement $z = \mathcal{N}(\hat{z}, S)$, with $S = H Σ H^T$, compute

\[\begin{aligned} K &= Σ^P H^T S^{-1}, \\ μ^F &= μ + K (0 - \hat{z}), \\ Σ^F &= Σ - K S K^T, -\end{aligned}\]

and return an updated state \mathcal{N}(μ^F, Σ^F). Note that this assumes zero-measurements. When called with ProbNumDiffEq.SquarerootMatrix type arguments it performs the update in Joseph / square-root form.

For better performance, we recommend to use the non-allocating update!.

source
ProbNumDiffEq.update!Function
update!(x_out, x_pred, measurement, H, K_cache, M_cache, S_cache)

In-place and square-root implementation of update which saves the result into x_out.

Implemented in Joseph Form to retain the PSDMatrix covariances:

\[\begin{aligned} +\end{aligned}\]

and return an updated state \mathcal{N}(μ^F, Σ^F). Note that this assumes zero-measurements. When called with ProbNumDiffEq.SquarerootMatrix type arguments it performs the update in Joseph / square-root form.

For better performance, we recommend to use the non-allocating update!.

source
ProbNumDiffEq.update!Function
update!(x_out, x_pred, measurement, H, K_cache, M_cache, S_cache)

In-place and square-root implementation of update which saves the result into x_out.

Implemented in Joseph Form to retain the PSDMatrix covariances:

\[\begin{aligned} K &= Σ^P H^T S^{-1}, \\ μ^F &= μ + K (0 - \hat{z}), \\ \sqrt{Σ}^F &= (I - KH) \sqrt(Σ), -\end{aligned}\]

where $\sqrt{M}$ denotes the left square-root of a matrix M, i.e. $M = \sqrt{M} \sqrt{M}^T$.

To prevent allocations, write into caches K_cache and M_cache, both of size D × D, and S_cache of same type as measurement.Σ.

See also: update.

source

Smooth

ProbNumDiffEq.smoothFunction
smooth(x_curr, x_next_smoothed, A, Q)

Update step of the Kalman smoother, aka. Rauch-Tung-Striebel smoother, for linear dynamics models.

Given Gaussians $x_n = \mathcal{N}(μ_{n}, Σ_{n})$ and $x_{n+1} = \mathcal{N}(μ_{n+1}^S, Σ_{n+1}^S)$, compute

\[\begin{aligned} +\end{aligned}\]

where $\sqrt{M}$ denotes the left square-root of a matrix M, i.e. $M = \sqrt{M} \sqrt{M}^T$.

To prevent allocations, write into caches K_cache and M_cache, both of size D × D, and S_cache of same type as measurement.Σ.

See also: update.

source

Smooth

ProbNumDiffEq.smoothFunction
smooth(x_curr, x_next_smoothed, A, Q)

Update step of the Kalman smoother, aka. Rauch-Tung-Striebel smoother, for linear dynamics models.

Given Gaussians $x_n = \mathcal{N}(μ_{n}, Σ_{n})$ and $x_{n+1} = \mathcal{N}(μ_{n+1}^S, Σ_{n+1}^S)$, compute

\[\begin{aligned} μ_{n+1}^P &= A μ_n^F, \\ P_{n+1}^P &= A Σ_n^F A + Q, \\ G &= Σ_n^S A^T (Σ_{n+1}^P)^{-1}, \\ μ_n^S &= μ_n^F + G (μ_{n+1}^S - μ_{n+1}^P), \\ Σ_n^S &= (I - G A) Σ_n^F (I - G A)^T + G Q G^T + G Σ_{n+1}^S G^T, -\end{aligned}\]

and return a smoothed state \mathcal{N}(μ_n^S, Σ_n^S). When called with ProbNumDiffEq.SquarerootMatrix type arguments it performs the update in Joseph / square-root form.

source

Markov Kernels

ProbNumDiffEq.AffineNormalKernelType
AffineNormalKernel(A[, b], C)

Structure to represent affine Normal Markov kernels, i.e. conditional distributions of the form

\[\begin{aligned} +\end{aligned}\]

and return a smoothed state \mathcal{N}(μ_n^S, Σ_n^S). When called with ProbNumDiffEq.SquarerootMatrix type arguments it performs the update in Joseph / square-root form.

source

Markov Kernels

ProbNumDiffEq.AffineNormalKernelType
AffineNormalKernel(A[, b], C)

Structure to represent affine Normal Markov kernels, i.e. conditional distributions of the form

\[\begin{aligned} y \mid x \sim \mathcal{N} \left( y; A x + b, C \right). -\end{aligned}\]

At the point of writing, AffineNormalKernels are only used to precompute and store the backward representation of the posterior (via compute_backward_kernel!) and for smoothing (via marginalize!).

source
ProbNumDiffEq.marginalize!Function
marginalize!(
     xout::Gaussian{Vector{T},PSDMatrix{T,S}}
     x::Gaussian{Vector{T},PSDMatrix{T,S}},
     K::AffineNormalKernel{<:AbstractMatrix,Union{<:Number,<:AbstractVector,Missing},<:PSDMatrix};
     C_DxD, C_3DxD
-)

Basically the same as predict!), but in kernel language and with support for affine transitions. At the time of writing, this is only used to smooth the posterior using it's backward representation, where the kernels are precomputed with compute_backward_kernel!.

Note that this function assumes certain shapes:

  • size(x.μ) == (D, D)
  • size(x.Σ) == (D, D)
  • size(K.A) == (D, D)
  • size(K.b) == (D,), or missing
  • size(K.C) == (D, D), _but with a tall square-root size(K.C.R) == (3D, D)

xout is assumes to have the same shapes as x.

source
ProbNumDiffEq.compute_backward_kernel!Function
compute_backward_kernel!(Kout, xpred, x, K; C_DxD[, diffusion=1])

Compute the backward representation of the posterior, i.e. the conditional distribution of the current state given the next state and the transition kernel.

More precisely, given a distribution (x)

\[\begin{aligned} +)

Basically the same as predict!), but in kernel language and with support for affine transitions. At the time of writing, this is only used to smooth the posterior using it's backward representation, where the kernels are precomputed with compute_backward_kernel!.

Note that this function assumes certain shapes:

  • size(x.μ) == (D, D)
  • size(x.Σ) == (D, D)
  • size(K.A) == (D, D)
  • size(K.b) == (D,), or missing
  • size(K.C) == (D, D), _but with a tall square-root size(K.C.R) == (3D, D)

xout is assumes to have the same shapes as x.

source
ProbNumDiffEq.compute_backward_kernel!Function
compute_backward_kernel!(Kout, xpred, x, K; C_DxD[, diffusion=1])

Compute the backward representation of the posterior, i.e. the conditional distribution of the current state given the next state and the transition kernel.

More precisely, given a distribution (x)

\[\begin{aligned} x \sim \mathcal{N} \left( x; μ, Σ \right), \end{aligned}\]

a kernel (K)

\[\begin{aligned} y \mid x \sim \mathcal{N} \left( y; A x + b, C \right), @@ -34,4 +34,4 @@ G &= Σ A^\top (Σ^P)^{-1}, \\ d &= μ - G μ^P, \\ Λ &= Σ - G Σ^P G^\top. -\end{aligned}\]

Everything is computed in square-root form and with minimal allocations (thus the cache C_DxD), so the actual formulas implemented here differ a bit.

The resulting backward kernels are used to smooth the posterior, via marginalize!.

source
+\end{aligned}\]

Everything is computed in square-root form and with minimal allocations (thus the cache C_DxD), so the actual formulas implemented here differ a bit.

The resulting backward kernels are used to smooth the posterior, via marginalize!.

source
diff --git a/previews/PR305/implementation/index.html b/previews/PR305/implementation/index.html index 5a60d9778..53cc4d378 100644 --- a/previews/PR305/implementation/index.html +++ b/previews/PR305/implementation/index.html @@ -1,2 +1,2 @@ -Implementation via OrdinaryDiffEq.jl · ProbNumDiffEq.jl

Solver Implementation via OrdinaryDiffEq.jl

ProbNumDiffEq.jl builds directly on OrdinaryDiffEq.jl to benefit from its iterator interface, flexible step-size control, and efficient Jacobian calculations. But, this requires extending non-public APIs. This page is meant to provide an overview on which parts exactly ProbNumDiffEq.jl builds on.

For more discussion on the pros and cons of building on OrdinaryDiffEq.jl, see this thread on discourse.

Building on OrdinaryDiffEq.jl

ProbNumDiffEq.jl shares most of OrdinaryDiffEq.jl's implementation. In particular:

  1. OrdinaryDiffEq.__init builds the cache and the integrator, and calls OrdinaryDiffEq.initialize!
  2. OrdinaryDiffEq.solve! implements the actual iterator structure, with
    • OrdinaryDiffEq.loopheader!
    • OrdinaryDiffEq.perform_step!
    • OrdinaryDiffEq.loopfooter!
    • OrdinaryDiffEq.postamble!

ProbNumDiffEq.jl builds around this structure and overloads some of the parts:

  • Algorithms: EK0/EK1 <: AbstractEK <: OrdinaryDiffEq.OrdinaryDiffEqAdaptiveAlgorithm
    • ./src/algorithms.jl provides the algorithms themselves
    • ./src/alg_utils.jl implements many traits (relating to automatic differentiation, implicitness, step-size control, etc)
  • Cache: EKCache <: AbstractODEFilterCache <: OrdinaryDiffEq.OrdinaryDiffEqCache
    • ./src/caches.jl implements the cache and its main constructor: OrdinaryDiffEq.alg_cache
  • Initialization and perform_step!: via OrdinaryDiffEq.initialize! and OrdinaryDiffEq.perform_step!. Implemented in ./src/perform_step.jl.
  • Custom postamble by overloading OrdinaryDiffEq.postamble! (which should always call OrdinaryDiffEq._postamble!). This is where we do the "smoothing" of the solution. Implemented in ./src/integrator_utils.jl.
  • Custom saving by overloading OrdinaryDiffEq.savevalues! (which should always call OrdinaryDiffEq._savevalues!). Implemented in ./src/integrator_utils.jl.

Building on DiffEqBase.jl

  • DiffEqBase.__init is currently overloaded to transform OOP problems into IIP problems (in ./src/solve.jl).
  • The solution object: ProbODESolution <: AbstractProbODESolution <: DiffEqBase.AbstractODESolution
    • ./src/solution.jl implements the main parts. Note that the main constructor DiffEqBase.build_solution is called by OrdinaryDiffEq.__init, so OrdinaryDiffEq.jl has control over its inputs.
    • MeanProbODESolution <: DiffEqBase.AbstractODESolution is a wrapper that allows handling the mean of a probabilistic ODE solution the same way one would handle any "standard" ODE solution, by just ignoring the covariances.
    • AbstractODEFilterPosterior <: DiffEqBase.AbstractDiffEqInterpolation handles the interpolation.
    • Plot recipe in ./ext/RecipesBaseExt.jl
    • Sampling in ./src/solution_sampling.jl
  • DiffEqBase.prepare_alg(::EK1{0}); closely follows a similar function implemented in OrdinaryDiffEq.jl ./src/alg_utils.jl
    • this also required DiffEqBase.remake(::EK1)

Other packages

  • DiffEqDevTools.appxtrue: We extend this function to work with ProbODESolution. This also enables DiffEqDevTools.WorkPrecision to work out of the box.
+Implementation via OrdinaryDiffEq.jl · ProbNumDiffEq.jl

Solver Implementation via OrdinaryDiffEq.jl

ProbNumDiffEq.jl builds directly on OrdinaryDiffEq.jl to benefit from its iterator interface, flexible step-size control, and efficient Jacobian calculations. But, this requires extending non-public APIs. This page is meant to provide an overview on which parts exactly ProbNumDiffEq.jl builds on.

For more discussion on the pros and cons of building on OrdinaryDiffEq.jl, see this thread on discourse.

Building on OrdinaryDiffEq.jl

ProbNumDiffEq.jl shares most of OrdinaryDiffEq.jl's implementation. In particular:

  1. OrdinaryDiffEq.__init builds the cache and the integrator, and calls OrdinaryDiffEq.initialize!
  2. OrdinaryDiffEq.solve! implements the actual iterator structure, with
    • OrdinaryDiffEq.loopheader!
    • OrdinaryDiffEq.perform_step!
    • OrdinaryDiffEq.loopfooter!
    • OrdinaryDiffEq.postamble!

ProbNumDiffEq.jl builds around this structure and overloads some of the parts:

  • Algorithms: EK0/EK1 <: AbstractEK <: OrdinaryDiffEq.OrdinaryDiffEqAdaptiveAlgorithm
    • ./src/algorithms.jl provides the algorithms themselves
    • ./src/alg_utils.jl implements many traits (relating to automatic differentiation, implicitness, step-size control, etc)
  • Cache: EKCache <: AbstractODEFilterCache <: OrdinaryDiffEq.OrdinaryDiffEqCache
    • ./src/caches.jl implements the cache and its main constructor: OrdinaryDiffEq.alg_cache
  • Initialization and perform_step!: via OrdinaryDiffEq.initialize! and OrdinaryDiffEq.perform_step!. Implemented in ./src/perform_step.jl.
  • Custom postamble by overloading OrdinaryDiffEq.postamble! (which should always call OrdinaryDiffEq._postamble!). This is where we do the "smoothing" of the solution. Implemented in ./src/integrator_utils.jl.
  • Custom saving by overloading OrdinaryDiffEq.savevalues! (which should always call OrdinaryDiffEq._savevalues!). Implemented in ./src/integrator_utils.jl.

Building on DiffEqBase.jl

  • DiffEqBase.__init is currently overloaded to transform OOP problems into IIP problems (in ./src/solve.jl).
  • The solution object: ProbODESolution <: AbstractProbODESolution <: DiffEqBase.AbstractODESolution
    • ./src/solution.jl implements the main parts. Note that the main constructor DiffEqBase.build_solution is called by OrdinaryDiffEq.__init, so OrdinaryDiffEq.jl has control over its inputs.
    • MeanProbODESolution <: DiffEqBase.AbstractODESolution is a wrapper that allows handling the mean of a probabilistic ODE solution the same way one would handle any "standard" ODE solution, by just ignoring the covariances.
    • AbstractODEFilterPosterior <: DiffEqBase.AbstractDiffEqInterpolation handles the interpolation.
    • Plot recipe in ./ext/RecipesBaseExt.jl
    • Sampling in ./src/solution_sampling.jl
  • DiffEqBase.prepare_alg(::EK1{0}); closely follows a similar function implemented in OrdinaryDiffEq.jl ./src/alg_utils.jl
    • this also required DiffEqBase.remake(::EK1)

Other packages

  • DiffEqDevTools.appxtrue: We extend this function to work with ProbODESolution. This also enables DiffEqDevTools.WorkPrecision to work out of the box.
diff --git a/previews/PR305/index.html b/previews/PR305/index.html index 03f0bb83a..30d982c51 100644 --- a/previews/PR305/index.html +++ b/previews/PR305/index.html @@ -1,3 +1,3 @@ Home · ProbNumDiffEq.jl

Probabilistic Numerical Differential Equation Solvers

Banner

ProbNumDiffEq.jl provides probabilistic numerical solvers to the DifferentialEquations.jl ecosystem. The implemented ODE filters solve differential equations via Bayesian filtering and smoothing and compute not just a single point estimate of the true solution, but a posterior distribution that contains an estimate of its numerical approximation error.

For a short intro video, check out our poster presentation at JuliaCon2021.

Installation

Run Julia, enter ] to bring up Julia's package manager, and add the ProbNumDiffEq.jl package:

julia> ]
-(v1.10) pkg> add ProbNumDiffEq

Getting Started

For a quick introduction check out the "Solving ODEs with Probabilistic Numerics" tutorial.

Features

  • probdiffeq: Fast and feature-rich filtering-based probabilistic ODE solvers in JAX.
  • ProbNum: Probabilistic numerics in Python. It has not only probabilistic ODE solvers, but also probabilistic linear solvers, Bayesian quadrature, and many filtering and smoothing implementations.
+(v1.10) pkg> add ProbNumDiffEq

Getting Started

For a quick introduction check out the "Solving ODEs with Probabilistic Numerics" tutorial.

Features

diff --git a/previews/PR305/initialization/index.html b/previews/PR305/initialization/index.html index 57f8c2535..a31b8810c 100644 --- a/previews/PR305/initialization/index.html +++ b/previews/PR305/initialization/index.html @@ -11,4 +11,4 @@ \end{aligned}\]

It is clear that this contains quite some information for $Y(0)$: The initial value $y_0$ and the vector field $f$ imply

\[\begin{aligned} Y^{(0)}(0) &= y_0, \\ Y^{(1)}(0) &= f(y_0, 0). -\end{aligned}\]

It turns out that we can also compute higher-order derivatives of $y$ with the chain rule, and then use these to better initialize $Y^{(i)}(0)$. This, done efficiently with Taylor-mode automatic differentiation by using TaylorIntegration.jl, is what TaylorModeInit does. See also [1].

In the vast majority of cases, just stick to the exact Taylor-mode initialization TaylorModeInit!

API

ProbNumDiffEq.TaylorModeInitType
TaylorModeInit(order)

Exact initialization via Taylor-mode automatic differentiation up to order order.

This is the recommended initialization method!

It uses TaylorIntegration.jl to efficiently compute the higher-order derivatives of the solution at the initial value, via Taylor-mode automatic differentiation.

In some special cases it can happen that TaylorIntegration.jl is incompatible with the given problem (typically because the problem definition does not allow for elements of type Taylor). If this happens, try one of SimpleInit, ForwardDiffInit (for low enough orders), ClassicSolverInit.

References

  • [7] Krämer et al, "Stable Implementation of Probabilistic ODE Solvers" (2020)
source
ProbNumDiffEq.ForwardDiffInitType
ForwardDiffInit(order)

Exact initialization via ForwardDiff.jl up to order order.

Warning: This does not scale well to high orders! For orders > 3, TaylorModeInit most likely performs better.

source
ProbNumDiffEq.SimpleInitType
SimpleInit()

Simple initialization, only with the given initial value and derivative.

The remaining derivatives are set to zero with unit covariance (unless specified otherwise by setting a custom FixedDiffusion).

source
ProbNumDiffEq.ClassicSolverInitType
ClassicSolverInit(; alg=OrdinaryDiffEq.Tsit5(), init_on_ddu=false)

Initialization via regression on a few steps of a classic ODE solver.

In a nutshell, instead of specifying $\mu_0$ exactly and setting $\Sigma_0=0$ (which is what TaylorModeInit does), use a classic ODE solver to compute a few steps of the solution, and then regress on the computed values (by running a smoother) to compute $\mu_0$ and $\Sigma_0$ as the mean and covariance of the smoothing posterior at time 0. See also [2].

The initial value and derivative are set directly from the given initial value problem; optionally the second derivative can also be set via automatic differentiation by setting init_on_ddu=true.

Arguments

  • alg: The solver to be used. Can be any solver from OrdinaryDiffEq.jl.
  • init_on_ddu: If true, the second derivative is also initialized exactly via automatic differentiation with ForwardDiff.jl.

References

  • [7] Krämer et al, "Stable Implementation of Probabilistic ODE Solvers" (2020)
  • [8] Schober et al, "A probabilistic model for the numerical solution of initial value problems", Statistics and Computing (2019)
source

References

[7]
N. Krämer and P. Hennig. Stable Implementation of Probabilistic ODE Solvers. CoRR (2020), arXiv:2012.10106 [stat.ML].
[8]
M. Schober, S. Särkkä and P. Hennig. A probabilistic model for the numerical solution of initial value problems. Statistics and Computing 29, 99–122 (2019).
+\end{aligned}\]

It turns out that we can also compute higher-order derivatives of $y$ with the chain rule, and then use these to better initialize $Y^{(i)}(0)$. This, done efficiently with Taylor-mode automatic differentiation by using TaylorIntegration.jl, is what TaylorModeInit does. See also [1].

In the vast majority of cases, just stick to the exact Taylor-mode initialization TaylorModeInit!

API

ProbNumDiffEq.TaylorModeInitType
TaylorModeInit(order)

Exact initialization via Taylor-mode automatic differentiation up to order order.

This is the recommended initialization method!

It uses TaylorIntegration.jl to efficiently compute the higher-order derivatives of the solution at the initial value, via Taylor-mode automatic differentiation.

In some special cases it can happen that TaylorIntegration.jl is incompatible with the given problem (typically because the problem definition does not allow for elements of type Taylor). If this happens, try one of SimpleInit, ForwardDiffInit (for low enough orders), ClassicSolverInit.

References

  • [7] Krämer et al, "Stable Implementation of Probabilistic ODE Solvers" (2020)
source
ProbNumDiffEq.ForwardDiffInitType
ForwardDiffInit(order)

Exact initialization via ForwardDiff.jl up to order order.

Warning: This does not scale well to high orders! For orders > 3, TaylorModeInit most likely performs better.

source
ProbNumDiffEq.SimpleInitType
SimpleInit()

Simple initialization, only with the given initial value and derivative.

The remaining derivatives are set to zero with unit covariance (unless specified otherwise by setting a custom FixedDiffusion).

source
ProbNumDiffEq.ClassicSolverInitType
ClassicSolverInit(; alg=OrdinaryDiffEq.Tsit5(), init_on_ddu=false)

Initialization via regression on a few steps of a classic ODE solver.

In a nutshell, instead of specifying $\mu_0$ exactly and setting $\Sigma_0=0$ (which is what TaylorModeInit does), use a classic ODE solver to compute a few steps of the solution, and then regress on the computed values (by running a smoother) to compute $\mu_0$ and $\Sigma_0$ as the mean and covariance of the smoothing posterior at time 0. See also [2].

The initial value and derivative are set directly from the given initial value problem; optionally the second derivative can also be set via automatic differentiation by setting init_on_ddu=true.

Arguments

  • alg: The solver to be used. Can be any solver from OrdinaryDiffEq.jl.
  • init_on_ddu: If true, the second derivative is also initialized exactly via automatic differentiation with ForwardDiff.jl.

References

  • [7] Krämer et al, "Stable Implementation of Probabilistic ODE Solvers" (2020)
  • [8] Schober et al, "A probabilistic model for the numerical solution of initial value problems", Statistics and Computing (2019)
source

References

[7]
N. Krämer and P. Hennig. Stable Implementation of Probabilistic ODE Solvers. CoRR (2020), arXiv:2012.10106 [stat.ML].
[8]
M. Schober, S. Särkkä and P. Hennig. A probabilistic model for the numerical solution of initial value problems. Statistics and Computing 29, 99–122 (2019).
diff --git a/previews/PR305/likelihoods/index.html b/previews/PR305/likelihoods/index.html index bf5b9755a..037488cc6 100644 --- a/previews/PR305/likelihoods/index.html +++ b/previews/PR305/likelihoods/index.html @@ -8,7 +8,7 @@ data, kwargs... ) -

Compute the Fenrir [3] approximate negative log-likelihood (NLL) of the data.

This is a convenience function that

  1. Solves the ODE with a ProbNumDiffEq.EK1 of the specified order and with a diffusion as provided by the diffusion_var argument, and
  2. Fits the ODE posterior to the data via Kalman filtering and thereby computes the log-likelihood of the data on the way.

You can control the step-size behaviour of the solver as you would for a standard ODE solve, but additionally the solver always steps through the data.t locations by adding them to tstops.

You can also choose steps adaptively by setting adaptive=true, but this is not well-tested so use at your own risk!

Arguments

Reference

source
ProbNumDiffEq.dalton_data_loglikFunction
dalton_data_loglik(
+

Compute the Fenrir [3] approximate negative log-likelihood (NLL) of the data.

This is a convenience function that

  1. Solves the ODE with a ProbNumDiffEq.EK1 of the specified order and with a diffusion as provided by the diffusion_var argument, and
  2. Fits the ODE posterior to the data via Kalman filtering and thereby computes the log-likelihood of the data on the way.

You can control the step-size behaviour of the solver as you would for a standard ODE solve, but additionally the solver always steps through the data.t locations by adding them to tstops.

You can also choose steps adaptively by setting adaptive=true, but this is not well-tested so use at your own risk!

Arguments

  • prob::SciMLBase.AbstractODEProblem: the initial value problem of interest
  • alg::AbstractEK: the probabilistic ODE solver to be used; use EK1 for best results.
  • data::NamedTuple{(:t, :u)}: the data to be fitted
  • observation_matrix::Union{AbstractMatrix,UniformScaling}: the matrix which maps the ODE state to the measurements; typically a projection matrix
  • observation_noise_cov::Union{Number,AbstractMatrix}: the scalar observation noise variance

Reference

  • [3] Tronarp et al, "Fenrir: Physics-Enhanced Regression for Initial Value Problems", ICML (2022)
source
ProbNumDiffEq.dalton_data_loglikFunction
dalton_data_loglik(
     prob::SciMLBase.AbstractODEProblem,
     alg::ProbNumDiffEq.AbstractEK,
     args...;
@@ -17,4 +17,4 @@
     data,
     kwargs...
 )
-

Compute the DALTON [10] approximate negative log-likelihood (NLL) of the data.

You can control the step-size behaviour of the solver as you would for a standard ODE solve, but additionally the solver always steps through the data.t locations by adding them to tstops. You can also choose steps adaptively by setting adaptive=true, but this is not well-tested so use at your own risk!

Arguments

  • prob::SciMLBase.AbstractODEProblem: the initial value problem of interest
  • alg::AbstractEK: the probabilistic ODE solver to be used; use EK1 for best results.
  • data::NamedTuple{(:t, :u)}: the data to be fitted
  • observation_matrix::Union{AbstractMatrix,UniformScaling}: the matrix which maps the ODE state to the measurements; typically a projection matrix
  • observation_noise_cov::Union{Number,AbstractMatrix}: the scalar observation noise variance

Reference

  • [10] Wu et al, "Data-Adaptive Probabilistic Likelihood Approximation for Ordinary Differential Equations", arXiv (2023)
source
+

Compute the DALTON [10] approximate negative log-likelihood (NLL) of the data.

You can control the step-size behaviour of the solver as you would for a standard ODE solve, but additionally the solver always steps through the data.t locations by adding them to tstops. You can also choose steps adaptively by setting adaptive=true, but this is not well-tested so use at your own risk!

Arguments

Reference

source diff --git a/previews/PR305/priors/150cadea.svg b/previews/PR305/priors/150cadea.svg new file mode 100644 index 000000000..5c239c928 --- /dev/null +++ b/previews/PR305/priors/150cadea.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/priors/237eeb04.svg b/previews/PR305/priors/237eeb04.svg new file mode 100644 index 000000000..2a79a53fa --- /dev/null +++ b/previews/PR305/priors/237eeb04.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/priors/312d20ed.svg b/previews/PR305/priors/312d20ed.svg new file mode 100644 index 000000000..1008a4d7e --- /dev/null +++ b/previews/PR305/priors/312d20ed.svg @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/priors/32064959.svg b/previews/PR305/priors/32064959.svg deleted file mode 100644 index 52f48098c..000000000 --- a/previews/PR305/priors/32064959.svg +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/previews/PR305/priors/334f9da8.svg b/previews/PR305/priors/334f9da8.svg deleted file mode 100644 index 39136b28c..000000000 --- a/previews/PR305/priors/334f9da8.svg +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/previews/PR305/priors/3ebe146d.svg b/previews/PR305/priors/3ebe146d.svg deleted file mode 100644 index 13dff1cb2..000000000 --- a/previews/PR305/priors/3ebe146d.svg +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/previews/PR305/priors/9c27750f.svg b/previews/PR305/priors/9c27750f.svg new file mode 100644 index 000000000..81443c2c3 --- /dev/null +++ b/previews/PR305/priors/9c27750f.svg @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/priors/9d2e0944.svg b/previews/PR305/priors/9d2e0944.svg deleted file mode 100644 index 6f9d71805..000000000 --- a/previews/PR305/priors/9d2e0944.svg +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/previews/PR305/priors/a1a57975.svg b/previews/PR305/priors/a1a57975.svg deleted file mode 100644 index e84c1a595..000000000 --- a/previews/PR305/priors/a1a57975.svg +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/previews/PR305/priors/eb04fb46.svg b/previews/PR305/priors/eb04fb46.svg new file mode 100644 index 000000000..04cc9afd5 --- /dev/null +++ b/previews/PR305/priors/eb04fb46.svg @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/priors/index.html b/previews/PR305/priors/index.html index 46432027d..b7cebfd34 100644 --- a/previews/PR305/priors/index.html +++ b/previews/PR305/priors/index.html @@ -10,7 +10,7 @@ \end{aligned}\]

defined as the solution of the stochastic differential equation

\[\begin{aligned} \text{d} Y^{(i)}(t) &= Y^{(i+1)}(t) \ \text{d}t, \qquad i = 0, \dots, q-1 \\ \text{d} Y^{(q)}(t) &= \Gamma \ \text{d}W(t). -\end{aligned}\]

Then, $Y^{(0)}(t)$ is the $q$-times integrated Wiener process (IWP) and $Y^{(i)}(t)$ is the $i$-th derivative of the IWP, for $i = 1, \dots, q$.

Examples

julia> solve(prob, EK1(prior=IWP(2)))
source

Here is how the IWP looks for varying smoothness parameters $q$:

using ProbNumDiffEq, Plots
+\end{aligned}\]

Then, $Y^{(0)}(t)$ is the $q$-times integrated Wiener process (IWP) and $Y^{(i)}(t)$ is the $i$-th derivative of the IWP, for $i = 1, \dots, q$.

Examples

julia> solve(prob, EK1(prior=IWP(2)))
source

Here is how the IWP looks for varying smoothness parameters $q$:

using ProbNumDiffEq, Plots
 plotrange = range(0, 10, length=250)
 plot(
     plot(IWP(1), plotrange; title="q=1"),
@@ -18,22 +18,22 @@
     plot(IWP(3), plotrange; title="q=3"),
     plot(IWP(4), plotrange; title="q=4");
     ylims=(-20,20),
-)
Example block output

In the context of ODE solvers, the smoothness parameter $q$ influences the convergence rate of the solver, and so it is typically chose similarly to the order of a Runge–Kutta method: lower order for low accuracy, higher order for high accuracy.

Integrated Ornstein–Uhlenbeck process (IOUP)

The $q$-times integrated Ornstein–Uhlenbeck process prior IOUP is a generalization of the IWP prior, where the drift matrix $\textcolor{#389826}{A}$ is not zero:

ProbNumDiffEq.IOUPType
IOUP([dim::Integer=1,]
+)
Example block output

In the context of ODE solvers, the smoothness parameter $q$ influences the convergence rate of the solver, and so it is typically chose similarly to the order of a Runge–Kutta method: lower order for low accuracy, higher order for high accuracy.

Integrated Ornstein–Uhlenbeck process (IOUP)

The $q$-times integrated Ornstein–Uhlenbeck process prior IOUP is a generalization of the IWP prior, where the drift matrix $\textcolor{#389826}{A}$ is not zero:

ProbNumDiffEq.IOUPType
IOUP([dim::Integer=1,]
      num_derivatives::Integer,
      rate_parameter::Union{Number,AbstractVector,AbstractMatrix})

Integrated Ornstein–Uhlenbeck process.

This prior is mostly used in the context of Probabilistic Exponential Integrators to include the linear part of a semi-linear ODE in the prior, so it is used in the ExpEK and the RosenbrockExpEK.

In math

The IOUP is a Gauss–Markov process, which we model with a state representation

\[\begin{aligned} Y(t) = \left[ Y^{(0)}(t), Y^{(1)}(t), \dots Y^{(q)}(t) \right], \end{aligned}\]

defined as the solution of the stochastic differential equation

\[\begin{aligned} \text{d} Y^{(i)}(t) &= Y^{(i+1)}(t) \ \text{d}t, \qquad i = 0, \dots, q-1 \\ \text{d} Y^{(q)}(t) &= L Y^{(q)}(t) \ \text{d}t + \Gamma \ \text{d}W(t), -\end{aligned}\]

where $L$ is called the rate_parameter. Then, $Y^{(0)}(t)$ is the $q$-times integrated Ornstein–Uhlenbeck process (IOUP) and $Y^{(i)}(t)$ is the $i$-th derivative of the IOUP, for $i = 1, \dots, q$.

Examples

julia> solve(prob, EK1(prior=IOUP(2, -1)))
source

Here is how the IOUP looks for varying rate parameters:

using ProbNumDiffEq, Plots
+\end{aligned}\]

where $L$ is called the rate_parameter. Then, $Y^{(0)}(t)$ is the $q$-times integrated Ornstein–Uhlenbeck process (IOUP) and $Y^{(i)}(t)$ is the $i$-th derivative of the IOUP, for $i = 1, \dots, q$.

Examples

julia> solve(prob, EK1(prior=IOUP(2, -1)))
source

Here is how the IOUP looks for varying rate parameters:

using ProbNumDiffEq, Plots
 plotrange = range(0, 10, length=250)
 plot(
     plot(IOUP(1, -1), plotrange; title="q=1,L=-1", ylims=(-20,20)),
     plot(IOUP(1, 1), plotrange; title="q=1,L=1", ylims=(-20,20)),
     plot(IOUP(4, -1), plotrange; title="q=4,L=-1", ylims=(-50,50)),
     plot(IOUP(4, 1), plotrange; title="q=4,L=1", ylims=(-50,50));
-)
Example block output

In the context of Probabilistic Exponential Integrators, the rate parameter is often chosen according to the given ODE. Here is an example for a damped oscillator:

plot(IOUP(dim=2, num_derivatives=1, rate_parameter=[-0.2 -2π; 2π -0.2]),
-     plotrange; plot_title="damped oscillator prior")
Example block output

Matérn process (Matern)

ProbNumDiffEq.MaternType
Matern([dim::Integer=1,]
+)
Example block output

In the context of Probabilistic Exponential Integrators, the rate parameter is often chosen according to the given ODE. Here is an example for a damped oscillator:

plot(IOUP(dim=2, num_derivatives=1, rate_parameter=[-0.2 -2π; 2π -0.2]),
+     plotrange; plot_title="damped oscillator prior")
Example block output

Matérn process (Matern)

ProbNumDiffEq.MaternType
Matern([dim::Integer=1,]
        num_derivatives::Integer,
        lengthscale::Number)

Matern process.

The class of Matern processes is well-known in the Gaussian process literature, and they also have a corresponding SDE representation similarly to the IWP and the IOUP. See also [6] for more details.

In math

A Matern process is a Gauss–Markov process, which we model with a state representation

\[\begin{aligned} Y(t) = \left[ Y^{(0)}(t), Y^{(1)}(t), \dots Y^{(q)}(t) \right], @@ -43,22 +43,22 @@ \begin{pmatrix} q+1 \\ j \end{pmatrix} \left( \frac{\sqrt{2q - 1}}{l} \right)^{q-j} Y^{(j)}(t) \right) \ \text{d}t + \Gamma \ \text{d}W(t). -\end{aligned}\]

where $l$ is called the lengthscale parameter. Then, $Y^{(0)}(t)$ is a Matern process and $Y^{(i)}(t)$ is the $i$-th derivative of this process, for $i = 1, \dots, q$.

Examples

julia> solve(prob, EK1(prior=Matern(2, 1)))
source

Here is how the Matern looks for varying smoothness parameters $q$:

using ProbNumDiffEq, Plots
+\end{aligned}\]

where $l$ is called the lengthscale parameter. Then, $Y^{(0)}(t)$ is a Matern process and $Y^{(i)}(t)$ is the $i$-th derivative of this process, for $i = 1, \dots, q$.

Examples

julia> solve(prob, EK1(prior=Matern(2, 1)))
source

Here is how the Matern looks for varying smoothness parameters $q$:

using ProbNumDiffEq, Plots
 plotrange = range(0, 10, length=250)
 plot(
     plot(Matern(1, 1), plotrange; title="q=1"),
     plot(Matern(2, 1), plotrange; title="q=2"),
     plot(Matern(3, 1), plotrange; title="q=3"),
     plot(Matern(4, 1), plotrange; title="q=4");
-)
Example block output

and for varying length scales $\ell$:

plot(
+)
Example block output

and for varying length scales $\ell$:

plot(
     plot(Matern(2, 5), plotrange; title="l=5"),
     plot(Matern(2, 2), plotrange; title="l=2"),
     plot(Matern(2, 1), plotrange; title="l=1"),
     plot(Matern(2, 0.5), plotrange; title="l=0.5"),
-)
Example block output

API

ProbNumDiffEq.AbstractGaussMarkovProcessType
AbstractGaussMarkovProcess{elType}

Abstract type for Gauss-Markov processes.

Gauss-Markov processes are solutions to linear time-invariant stochastic differential equations (SDEs). Here we assume SDEs of the form

\[\begin{aligned} +)

Example block output

API

ProbNumDiffEq.AbstractGaussMarkovProcessType
AbstractGaussMarkovProcess{elType}

Abstract type for Gauss-Markov processes.

Gauss-Markov processes are solutions to linear time-invariant stochastic differential equations (SDEs). Here we assume SDEs of the form

\[\begin{aligned} dX_t &= F X_t dt + L dW_t \\ X_0 &= \mathcal{N} \left( X_0; \mu_0, \Sigma_0 \right) -\end{aligned}\]

where $X_t$ is the state, $W_t$ is a Wiener process, and $F$ and $L$ are matrices.

Currently, ProbNumDiffEq.jl makes many assumptions about the structure of the SDEs that it can solve. In particular, it assumes that the state vector $X_t$ contains a range of dervatives, and that the Wiener process only enters the highest one. It also assumes a certain ordering of dimensions and derivatives. This is not a limitation of the underlying mathematics, but rather a limitation of the current implementation. In the future, we hope to remove these limitations.

Warning

We currently strongly recommended to not implement your own Gauss-Markov process by subtyping this type! The interface is not yet stable, and the implementation is not yet sufficiently documented. Proceed at your own risk.

source
ProbNumDiffEq.LTISDEType
LTISDE(F::AbstractMatrix, L::AbstractMatrix)

Linear time-invariant stochastic differential equation.

A LTI-SDE is a stochastic differential equation of the form

\[dX_t = F X_t dt + L dW_t\]

where $X_t$ is the state, $W_t$ is a Wiener process, and $F$ and $L$ are matrices. This LTISDE object holds the matrices $F$ and $L$. It also provides some functionality to discretize the SDE via a matrix-fraction decomposition. See: discretize(::LTISDE, ::Real).

source
ProbNumDiffEq.dimFunction
dim(p::AbstractGaussMarkovProcess)

Return the dimension of the process.

This is not the dimension of the "state" that is used to efficiently model the prior process as a state-space model, but it is the dimension of the process itself that we aim to model.

See AbstractGaussMarkovProcess for more details on Gauss-Markov processes in ProbNumDiffEq.

source
ProbNumDiffEq.to_sdeFunction
to_sde(p::AbstractGaussMarkovProcess)

Convert the prior to the corresponding SDE.

Gauss-Markov processes are solutions to linear time-invariant stochastic differential equations (SDEs) of the form

\[\begin{aligned} +\end{aligned}\]

where $X_t$ is the state, $W_t$ is a Wiener process, and $F$ and $L$ are matrices.

Currently, ProbNumDiffEq.jl makes many assumptions about the structure of the SDEs that it can solve. In particular, it assumes that the state vector $X_t$ contains a range of dervatives, and that the Wiener process only enters the highest one. It also assumes a certain ordering of dimensions and derivatives. This is not a limitation of the underlying mathematics, but rather a limitation of the current implementation. In the future, we hope to remove these limitations.

Warning

We currently strongly recommended to not implement your own Gauss-Markov process by subtyping this type! The interface is not yet stable, and the implementation is not yet sufficiently documented. Proceed at your own risk.

source
ProbNumDiffEq.LTISDEType
LTISDE(F::AbstractMatrix, L::AbstractMatrix)

Linear time-invariant stochastic differential equation.

A LTI-SDE is a stochastic differential equation of the form

\[dX_t = F X_t dt + L dW_t\]

where $X_t$ is the state, $W_t$ is a Wiener process, and $F$ and $L$ are matrices. This LTISDE object holds the matrices $F$ and $L$. It also provides some functionality to discretize the SDE via a matrix-fraction decomposition. See: discretize(::LTISDE, ::Real).

source
ProbNumDiffEq.dimFunction
dim(p::AbstractGaussMarkovProcess)

Return the dimension of the process.

This is not the dimension of the "state" that is used to efficiently model the prior process as a state-space model, but it is the dimension of the process itself that we aim to model.

See AbstractGaussMarkovProcess for more details on Gauss-Markov processes in ProbNumDiffEq.

source
ProbNumDiffEq.to_sdeFunction
to_sde(p::AbstractGaussMarkovProcess)

Convert the prior to the corresponding SDE.

Gauss-Markov processes are solutions to linear time-invariant stochastic differential equations (SDEs) of the form

\[\begin{aligned} dX_t &= F X_t dt + L dW_t \\ X_0 &= \mathcal{N} \left( X_0; \mu_0, \Sigma_0 \right) -\end{aligned}\]

where $X_t$ is the state, $W_t$ is a Wiener process, and $F$ and $L$ are matrices. This function returns the corresponding SDE, i.e. the matrices $F$ and $L$, as a LTISDE.

source
ProbNumDiffEq.discretizeFunction
discretize(p::AbstractGaussMarkovProcess, step_size::Real)

Compute the transition matrices of the process for a given step size.

source
discretize(p::LTISDE, step_size::Real)

Compute the transition matrices of the SDE solution for a given step size.

source
ProbNumDiffEq.initial_distributionFunction
initial_distribution(p::AbstractGaussMarkovProcess)

Return the initial distribution of the process.

Currently this is always a Gaussian distribution with zero mean and unit variance, unless explicitly overwitten (e.g. for Matern processes to have the stationary distribution). This implementation is likely to change in the future to allow for more flexibility.

source

Convenience functions to analyze and visualize priors

ProbNumDiffEq.marginalizeFunction
marginalize(process::AbstractGaussMarkovProcess, times)

Compute the marginal distributions of the process at the given time points.

This function computes the marginal distributions of the process at the given times. It does so by discretizing the process with the given step sizes (using ProbNumDiffEq.discretize), and then computing the marginal distributions of the resulting Gaussian distributions.

See also: sample.

source
+\end{aligned}\]

where $X_t$ is the state, $W_t$ is a Wiener process, and $F$ and $L$ are matrices. This function returns the corresponding SDE, i.e. the matrices $F$ and $L$, as a LTISDE.

source
ProbNumDiffEq.discretizeFunction
discretize(p::AbstractGaussMarkovProcess, step_size::Real)

Compute the transition matrices of the process for a given step size.

source
discretize(p::LTISDE, step_size::Real)

Compute the transition matrices of the SDE solution for a given step size.

source
ProbNumDiffEq.initial_distributionFunction
initial_distribution(p::AbstractGaussMarkovProcess)

Return the initial distribution of the process.

Currently this is always a Gaussian distribution with zero mean and unit variance, unless explicitly overwitten (e.g. for Matern processes to have the stationary distribution). This implementation is likely to change in the future to allow for more flexibility.

source

Convenience functions to analyze and visualize priors

ProbNumDiffEq.marginalizeFunction
marginalize(process::AbstractGaussMarkovProcess, times)

Compute the marginal distributions of the process at the given time points.

This function computes the marginal distributions of the process at the given times. It does so by discretizing the process with the given step sizes (using ProbNumDiffEq.discretize), and then computing the marginal distributions of the resulting Gaussian distributions.

See also: sample.

source
diff --git a/previews/PR305/references/index.html b/previews/PR305/references/index.html index d9acdf470..aca25f9f3 100644 --- a/previews/PR305/references/index.html +++ b/previews/PR305/references/index.html @@ -1,2 +1,2 @@ -References · ProbNumDiffEq.jl

References

[1]
N. Bosch, F. Tronarp and P. Hennig. Pick-and-Mix Information Operators for Probabilistic ODE Solvers. In: Proceedings of The 25th International Conference on Artificial Intelligence and Statistics, Vol. 151 of Proceedings of Machine Learning Research, edited by G. Camps-Valls, F. J. Ruiz and I. Valera (PMLR, 28–30 Mar 2022); pp. 10015–10027.
[2]
N. Bosch, P. Hennig and F. Tronarp. Probabilistic Exponential Integrators. In: Thirty-seventh Conference on Neural Information Processing Systems (2023).
[3]
F. Tronarp, N. Bosch and P. Hennig. Fenrir: Physics-Enhanced Regression for Initial Value Problems. In: Proceedings of the 39th International Conference on Machine Learning, Vol. 162 of Proceedings of Machine Learning Research, edited by K. Chaudhuri, S. Jegelka, L. Song, C. Szepesvari, G. Niu and S. Sabato (PMLR, 17–23 Jul 2022); pp. 21776–21794.
[4]
[5]
N. Krämer, N. Bosch, J. Schmidt and P. Hennig. Probabilistic ODE Solutions in Millions of Dimensions. In: Proceedings of the 39th International Conference on Machine Learning, Vol. 162 of Proceedings of Machine Learning Research, edited by K. Chaudhuri, S. Jegelka, L. Song, C. Szepesvari, G. Niu and S. Sabato (PMLR, 17–23 Jul 2022); pp. 11634–11649.
[6]
S. Särkkä and A. Solin. Applied Stochastic Differential Equations. Institute of Mathematical Statistics Textbooks (Cambridge University Press, 2019).
[7]
[8]
[9]
N. Bosch, P. Hennig and F. Tronarp. Calibrated Adaptive Probabilistic ODE Solvers. In: Proceedings of The 24th International Conference on Artificial Intelligence and Statistics, Vol. 130 of Proceedings of Machine Learning Research, edited by A. Banerjee and K. Fukumizu (PMLR, 13–15 Apr 2021); pp. 3466–3474.
[10]
[11]
P. Hennig, M. A. Osborne and H. P. Kersting. Probabilistic Numerics: Computation as Machine Learning (Cambridge University Press, 2022).
[12]
H. Kersting and P. Hennig. Active Uncertainty Calibration in Bayesian ODE Solvers. In: Proceedings of the Thirty-Second Conference on Uncertainty in Artificial Intelligence, UAI'16 (AUAI Press, 2016); pp. 309–318.
[13]
H. Kersting, T. J. Sullivan and P. Hennig. Convergence rates of Gaussian ODE filters. Statistics and Computing 30, 1791–1816 (2020).
[14]
+References · ProbNumDiffEq.jl

References

[1]
N. Bosch, F. Tronarp and P. Hennig. Pick-and-Mix Information Operators for Probabilistic ODE Solvers. In: Proceedings of The 25th International Conference on Artificial Intelligence and Statistics, Vol. 151 of Proceedings of Machine Learning Research, edited by G. Camps-Valls, F. J. Ruiz and I. Valera (PMLR, 28–30 Mar 2022); pp. 10015–10027.
[2]
N. Bosch, P. Hennig and F. Tronarp. Probabilistic Exponential Integrators. In: Thirty-seventh Conference on Neural Information Processing Systems (2023).
[3]
F. Tronarp, N. Bosch and P. Hennig. Fenrir: Physics-Enhanced Regression for Initial Value Problems. In: Proceedings of the 39th International Conference on Machine Learning, Vol. 162 of Proceedings of Machine Learning Research, edited by K. Chaudhuri, S. Jegelka, L. Song, C. Szepesvari, G. Niu and S. Sabato (PMLR, 17–23 Jul 2022); pp. 21776–21794.
[4]
[5]
N. Krämer, N. Bosch, J. Schmidt and P. Hennig. Probabilistic ODE Solutions in Millions of Dimensions. In: Proceedings of the 39th International Conference on Machine Learning, Vol. 162 of Proceedings of Machine Learning Research, edited by K. Chaudhuri, S. Jegelka, L. Song, C. Szepesvari, G. Niu and S. Sabato (PMLR, 17–23 Jul 2022); pp. 11634–11649.
[6]
S. Särkkä and A. Solin. Applied Stochastic Differential Equations. Institute of Mathematical Statistics Textbooks (Cambridge University Press, 2019).
[7]
[8]
[9]
N. Bosch, P. Hennig and F. Tronarp. Calibrated Adaptive Probabilistic ODE Solvers. In: Proceedings of The 24th International Conference on Artificial Intelligence and Statistics, Vol. 130 of Proceedings of Machine Learning Research, edited by A. Banerjee and K. Fukumizu (PMLR, 13–15 Apr 2021); pp. 3466–3474.
[10]
[11]
P. Hennig, M. A. Osborne and H. P. Kersting. Probabilistic Numerics: Computation as Machine Learning (Cambridge University Press, 2022).
[12]
H. Kersting and P. Hennig. Active Uncertainty Calibration in Bayesian ODE Solvers. In: Proceedings of the Thirty-Second Conference on Uncertainty in Artificial Intelligence, UAI'16 (AUAI Press, 2016); pp. 309–318.
[13]
H. Kersting, T. J. Sullivan and P. Hennig. Convergence rates of Gaussian ODE filters. Statistics and Computing 30, 1791–1816 (2020).
[14]
diff --git a/previews/PR305/solvers/index.html b/previews/PR305/solvers/index.html index 0fc4d1a08..692a5b34a 100644 --- a/previews/PR305/solvers/index.html +++ b/previews/PR305/solvers/index.html @@ -4,10 +4,10 @@ prior=IWP(order), diffusionmodel=DynamicDiffusion(), initialization=TaylorModeInit(num_derivatives(prior)), - kwargs...)

Gaussian ODE filter with first-order vector field linearization.

This is a semi-implicit, L-stable ODE solver so it can handle stiffness quite well [4], and it generally produces more expressive posterior covariances than the EK0. However, as typical implicit ODE solvers it scales cubically with the ODE dimension [5], so if you're solving a high-dimensional non-stiff problem you might want to give the EK0 a try.

Arguments

Some additional kwargs relating to implicit solvers are supported; check out DifferentialEquations.jl's Extra Options page. Right now, we support autodiff, chunk_size, and diff_type. In particular, autodiff=false can come in handy to use finite differences instead of ForwardDiff.jl to compute Jacobians.

Examples

julia> solve(prob, EK1())

References

source
ProbNumDiffEq.EK0Type
EK0(; order=3,
+      kwargs...)

Gaussian ODE filter with first-order vector field linearization.

This is a semi-implicit, L-stable ODE solver so it can handle stiffness quite well [4], and it generally produces more expressive posterior covariances than the EK0. However, as typical implicit ODE solvers it scales cubically with the ODE dimension [5], so if you're solving a high-dimensional non-stiff problem you might want to give the EK0 a try.

Arguments

  • order::Integer: Order of the integrated Wiener process (IWP) prior.
  • smooth::Bool: Turn smoothing on/off; smoothing is required for dense output.
  • prior::AbstractGaussMarkovProcess: Prior to be used by the ODE filter. By default, uses a 3-times integrated Wiener process prior IWP(3). See also: Priors.
  • diffusionmodel::ProbNumDiffEq.AbstractDiffusion: See Diffusion models and calibration.
  • initialization::ProbNumDiffEq.InitializationScheme: See Initialization.

Some additional kwargs relating to implicit solvers are supported; check out DifferentialEquations.jl's Extra Options page. Right now, we support autodiff, chunk_size, and diff_type. In particular, autodiff=false can come in handy to use finite differences instead of ForwardDiff.jl to compute Jacobians.

Examples

julia> solve(prob, EK1())

References

source
ProbNumDiffEq.EK0Type
EK0(; order=3,
       smooth=true,
       prior=IWP(order),
       diffusionmodel=DynamicDiffusion(),
-      initialization=TaylorModeInit(num_derivatives(prior)))

Gaussian ODE filter with zeroth-order vector field linearization.

This is an explicit ODE solver. It is fast and scales well to high-dimensional problems [5], but it is not L-stable [4]. So for stiff problems, use the EK1.

Whenever possible this solver will use a Kronecker-factored implementation to achieve its linear scaling and to get the best runtimes. This can currently be done only with an IWP prior (default), with a scalar diffusion model (either DynamicDiffusion or FixedDiffusion). For other configurations the solver falls back to a dense implementation which scales cubically with the problem size.

Arguments

  • order::Integer: Order of the integrated Wiener process (IWP) prior.
  • smooth::Bool: Turn smoothing on/off; smoothing is required for dense output.
  • prior::AbstractGaussMarkovProcess: Prior to be used by the ODE filter. By default, uses a 3-times integrated Wiener process prior IWP(3). See also: Priors.
  • diffusionmodel::ProbNumDiffEq.AbstractDiffusion: See Diffusion models and calibration.
  • initialization::ProbNumDiffEq.InitializationScheme: See Initialization.

Examples

julia> solve(prob, EK0())

References

source

Probabilistic Exponential Integrators

ProbNumDiffEq.ExpEKFunction
ExpEK(; L, order=3, kwargs...)

Probabilistic exponential integrator

Probabilistic exponential integrators are a class of integrators for semi-linear stiff ODEs that provide improved stability by essentially solving the linear part of the ODE exactly. In probabilistic numerics, this amounts to including the linear part into the prior model of the solver.

ExpEK is therefore just a short-hand for EK0 with IOUP prior:

ExpEK(; order=3, L, kwargs...) = EK0(; prior=IOUP(order, L), kwargs...)

See also RosenbrockExpEK, EK0, EK1.

Arguments

See EK0 for available keyword arguments.

Examples

julia> prob = ODEProblem((du, u, p, t) -> (@. du = - u + sin(u)), [1.0], (0.0, 10.0))
-julia> solve(prob, ExpEK(L=-1))

Reference

  • [2] Bosch et al, "Probabilistic Exponential Integrators", arXiv (2021)
source
ProbNumDiffEq.RosenbrockExpEKFunction
RosenbrockExpEK(; order=3, kwargs...)

Probabilistic Rosenbrock-type exponential integrator

A probabilistic exponential integrator similar to ExpEK, but with automatic linearization along the mean numerical solution. This brings the advantage that the linearity does not need to be specified manually, and the more accurate local linearization can sometimes also improve stability; but since the "prior" is adjusted at each step the probabilistic interpretation becomes more complicated.

RosenbrockExpEK is just a short-hand for EK1 with locally-updated IOUP prior:

RosenbrockExpEK(; order=3, kwargs...) = EK1(; prior=IOUP(order, update_rate_parameter=true), kwargs...)

See also ExpEK, EK0, EK1.

Arguments

See EK1 for available keyword arguments.

Examples

julia> prob = ODEProblem((du, u, p, t) -> (@. du = - u + sin(u)), [1.0], (0.0, 10.0))
-julia> solve(prob, RosenbrockExpEK())

Reference

  • [2] Bosch et al, "Probabilistic Exponential Integrators", NeurIPS (2023)
source

References

[4]
F. Tronarp, H. Kersting, S. Särkkä and P. Hennig. Probabilistic solutions to ordinary differential equations as nonlinear Bayesian filtering: a new perspective. Statistics and Computing 29, 1297–1315 (2019).
[5]
N. Krämer, N. Bosch, J. Schmidt and P. Hennig. Probabilistic ODE Solutions in Millions of Dimensions. In: Proceedings of the 39th International Conference on Machine Learning, Vol. 162 of Proceedings of Machine Learning Research, edited by K. Chaudhuri, S. Jegelka, L. Song, C. Szepesvari, G. Niu and S. Sabato (PMLR, 17–23 Jul 2022); pp. 11634–11649.
[2]
N. Bosch, P. Hennig and F. Tronarp. Probabilistic Exponential Integrators. In: Thirty-seventh Conference on Neural Information Processing Systems (2023).
+ initialization=TaylorModeInit(num_derivatives(prior)))

Gaussian ODE filter with zeroth-order vector field linearization.

This is an explicit ODE solver. It is fast and scales well to high-dimensional problems [5], but it is not L-stable [4]. So for stiff problems, use the EK1.

Whenever possible this solver will use a Kronecker-factored implementation to achieve its linear scaling and to get the best runtimes. This can currently be done only with an IWP prior (default), with a scalar diffusion model (either DynamicDiffusion or FixedDiffusion). For other configurations the solver falls back to a dense implementation which scales cubically with the problem size.

Arguments

Examples

julia> solve(prob, EK0())

References

source

Probabilistic Exponential Integrators

ProbNumDiffEq.ExpEKFunction
ExpEK(; L, order=3, kwargs...)

Probabilistic exponential integrator

Probabilistic exponential integrators are a class of integrators for semi-linear stiff ODEs that provide improved stability by essentially solving the linear part of the ODE exactly. In probabilistic numerics, this amounts to including the linear part into the prior model of the solver.

ExpEK is therefore just a short-hand for EK0 with IOUP prior:

ExpEK(; order=3, L, kwargs...) = EK0(; prior=IOUP(order, L), kwargs...)

See also RosenbrockExpEK, EK0, EK1.

Arguments

See EK0 for available keyword arguments.

Examples

julia> prob = ODEProblem((du, u, p, t) -> (@. du = - u + sin(u)), [1.0], (0.0, 10.0))
+julia> solve(prob, ExpEK(L=-1))

Reference

  • [2] Bosch et al, "Probabilistic Exponential Integrators", arXiv (2021)
source
ProbNumDiffEq.RosenbrockExpEKFunction
RosenbrockExpEK(; order=3, kwargs...)

Probabilistic Rosenbrock-type exponential integrator

A probabilistic exponential integrator similar to ExpEK, but with automatic linearization along the mean numerical solution. This brings the advantage that the linearity does not need to be specified manually, and the more accurate local linearization can sometimes also improve stability; but since the "prior" is adjusted at each step the probabilistic interpretation becomes more complicated.

RosenbrockExpEK is just a short-hand for EK1 with locally-updated IOUP prior:

RosenbrockExpEK(; order=3, kwargs...) = EK1(; prior=IOUP(order, update_rate_parameter=true), kwargs...)

See also ExpEK, EK0, EK1.

Arguments

See EK1 for available keyword arguments.

Examples

julia> prob = ODEProblem((du, u, p, t) -> (@. du = - u + sin(u)), [1.0], (0.0, 10.0))
+julia> solve(prob, RosenbrockExpEK())

Reference

  • [2] Bosch et al, "Probabilistic Exponential Integrators", NeurIPS (2023)
source

References

[4]
F. Tronarp, H. Kersting, S. Särkkä and P. Hennig. Probabilistic solutions to ordinary differential equations as nonlinear Bayesian filtering: a new perspective. Statistics and Computing 29, 1297–1315 (2019).
[5]
N. Krämer, N. Bosch, J. Schmidt and P. Hennig. Probabilistic ODE Solutions in Millions of Dimensions. In: Proceedings of the 39th International Conference on Machine Learning, Vol. 162 of Proceedings of Machine Learning Research, edited by K. Chaudhuri, S. Jegelka, L. Song, C. Szepesvari, G. Niu and S. Sabato (PMLR, 17–23 Jul 2022); pp. 11634–11649.
[2]
N. Bosch, P. Hennig and F. Tronarp. Probabilistic Exponential Integrators. In: Thirty-seventh Conference on Neural Information Processing Systems (2023).
diff --git a/previews/PR305/tutorials/dae/92d6b6f6.svg b/previews/PR305/tutorials/dae/acdff63c.svg similarity index 99% rename from previews/PR305/tutorials/dae/92d6b6f6.svg rename to previews/PR305/tutorials/dae/acdff63c.svg index 3acf99973..887a0a525 100644 --- a/previews/PR305/tutorials/dae/92d6b6f6.svg +++ b/previews/PR305/tutorials/dae/acdff63c.svg @@ -1,59 +1,59 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/dae/f900dfcf.svg b/previews/PR305/tutorials/dae/b8457e2f.svg similarity index 99% rename from previews/PR305/tutorials/dae/f900dfcf.svg rename to previews/PR305/tutorials/dae/b8457e2f.svg index 2e687c2cc..f0a576e27 100644 --- a/previews/PR305/tutorials/dae/f900dfcf.svg +++ b/previews/PR305/tutorials/dae/b8457e2f.svg @@ -1,90 +1,90 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/dae/index.html b/previews/PR305/tutorials/dae/index.html index 9d20ae79a..06550afb8 100644 --- a/previews/PR305/tutorials/dae/index.html +++ b/previews/PR305/tutorials/dae/index.html @@ -28,7 +28,7 @@ ylabel=["u₁(t)" "u₂(t)" "u₃(t)"], xlabel=["" "" "t"], denseplot=false, -)Example block output

Looks good!

Solving an Index-3 DAE directly

The following is based on the "Automatic Index Reduction of DAEs" tutorial by ModelingToolkit.jl, which demonstrates how the classic Rodas4 solver fails to solve a DAE due to the fact that it is of index 3; which is why ModelingToolkit's automatic index reduction is so useful.

It turns out that our probabilistic numerical solvers can directly solve the index-3 DAE!

First, define the pendulum problem as in the tutorial:

function pendulum!(du, u, p, t)
+)
Example block output

Looks good!

Solving an Index-3 DAE directly

The following is based on the "Automatic Index Reduction of DAEs" tutorial by ModelingToolkit.jl, which demonstrates how the classic Rodas4 solver fails to solve a DAE due to the fact that it is of index 3; which is why ModelingToolkit's automatic index reduction is so useful.

It turns out that our probabilistic numerical solvers can directly solve the index-3 DAE!

First, define the pendulum problem as in the tutorial:

function pendulum!(du, u, p, t)
     x, dx, y, dy, T = u
     g, L = p
     du[1] = dx
@@ -104,7 +104,7 @@
  [0.957940002319977, -0.6813737682784675, -0.28696857832357914, -2.2722969869869667, -8.475874423432991]
  [0.9513764315907425, -0.7580420941403236, -0.3080306846666298, -2.337925795788078, -9.10937542703355]
  [0.9455309355620407, -0.8238465818165532, -0.325532285560256, -2.388489111563977, -9.638156836814543]
- [0.944566419026587, -0.8345069039015303, -0.3283203924231612, -2.3962208016104234, -9.722642388563708]

Nope! The EK1 is able to solve the index-3 DAE directly. Pretty cool!

plot(sol)
Example block output

Is index-reduction still worth it?

The point of the "Automatic Index Reduction of DAEs" tutorial is to demonstrate ModelingToolkit's utility for automatic index reduction, which enables the classic implicit Runge-Kutta solvers such as Rodas5 to solve this DAE. Let's see if that still helps in this context here.

First, modelingtoolkitize the problem:

traced_sys = modelingtoolkitize(pendulum_prob)

\[ \begin{align} + [0.944566419026587, -0.8345069039015303, -0.3283203924231612, -2.3962208016104234, -9.722642388563708]

Nope! The EK1 is able to solve the index-3 DAE directly. Pretty cool!

plot(sol)
Example block output

Is index-reduction still worth it?

The point of the "Automatic Index Reduction of DAEs" tutorial is to demonstrate ModelingToolkit's utility for automatic index reduction, which enables the classic implicit Runge-Kutta solvers such as Rodas5 to solve this DAE. Let's see if that still helps in this context here.

First, modelingtoolkitize the problem:

traced_sys = modelingtoolkitize(pendulum_prob)

\[ \begin{align} \frac{\mathrm{d} x_1\left( t \right)}{\mathrm{d}t} =& x_2\left( t \right) \\ \frac{\mathrm{d} x_2\left( t \right)}{\mathrm{d}t} =& x_1\left( t \right) x_5\left( t \right) \\ \frac{\mathrm{d} x_3\left( t \right)}{\mathrm{d}t} =& x_4\left( t \right) \\ @@ -130,4 +130,4 @@ sol1_f_evals = sol1.stats.nf sol3_final_error = norm(sol3.u[end] - truesol.u[end]) sol3_f_evals = sol3.stats.nf -@info "Results" sol1_final_error sol1_f_evals sol3_final_error sol3_f_evals

The error for the index-1 DAE solve is much lower. Thus it seems that, even if the index-3 DAE could also be solved directly, index lowering might still be beneficial when solving DAEs with the EK1!

References

[1]
N. Bosch, F. Tronarp and P. Hennig. Pick-and-Mix Information Operators for Probabilistic ODE Solvers. In: Proceedings of The 25th International Conference on Artificial Intelligence and Statistics, Vol. 151 of Proceedings of Machine Learning Research, edited by G. Camps-Valls, F. J. Ruiz and I. Valera (PMLR, 28–30 Mar 2022); pp. 10015–10027.
+@info "Results" sol1_final_error sol1_f_evals sol3_final_error sol3_f_evals

The error for the index-1 DAE solve is much lower. Thus it seems that, even if the index-3 DAE could also be solved directly, index lowering might still be beneficial when solving DAEs with the EK1!

References

[1]
N. Bosch, F. Tronarp and P. Hennig. Pick-and-Mix Information Operators for Probabilistic ODE Solvers. In: Proceedings of The 25th International Conference on Artificial Intelligence and Statistics, Vol. 151 of Proceedings of Machine Learning Research, edited by G. Camps-Valls, F. J. Ruiz and I. Valera (PMLR, 28–30 Mar 2022); pp. 10015–10027.
diff --git a/previews/PR305/tutorials/dynamical_odes/040b01ee.svg b/previews/PR305/tutorials/dynamical_odes/35d9e954.svg similarity index 97% rename from previews/PR305/tutorials/dynamical_odes/040b01ee.svg rename to previews/PR305/tutorials/dynamical_odes/35d9e954.svg index cf3ae1a2c..1ea4ec7fe 100644 --- a/previews/PR305/tutorials/dynamical_odes/040b01ee.svg +++ b/previews/PR305/tutorials/dynamical_odes/35d9e954.svg @@ -1,46 +1,46 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/dynamical_odes/9ea1717f.svg b/previews/PR305/tutorials/dynamical_odes/55e751ef.svg similarity index 98% rename from previews/PR305/tutorials/dynamical_odes/9ea1717f.svg rename to previews/PR305/tutorials/dynamical_odes/55e751ef.svg index 7d109ff21..c893a90bb 100644 --- a/previews/PR305/tutorials/dynamical_odes/9ea1717f.svg +++ b/previews/PR305/tutorials/dynamical_odes/55e751ef.svg @@ -1,46 +1,46 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/dynamical_odes/b71f2d85.svg b/previews/PR305/tutorials/dynamical_odes/7334cb06.svg similarity index 98% rename from previews/PR305/tutorials/dynamical_odes/b71f2d85.svg rename to previews/PR305/tutorials/dynamical_odes/7334cb06.svg index ca44c85a7..971c488b6 100644 --- a/previews/PR305/tutorials/dynamical_odes/b71f2d85.svg +++ b/previews/PR305/tutorials/dynamical_odes/7334cb06.svg @@ -1,50 +1,50 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/dynamical_odes/6ea3b8f2.svg b/previews/PR305/tutorials/dynamical_odes/d117fca1.svg similarity index 99% rename from previews/PR305/tutorials/dynamical_odes/6ea3b8f2.svg rename to previews/PR305/tutorials/dynamical_odes/d117fca1.svg index d47de63f9..264e5ad63 100644 --- a/previews/PR305/tutorials/dynamical_odes/6ea3b8f2.svg +++ b/previews/PR305/tutorials/dynamical_odes/d117fca1.svg @@ -1,52 +1,52 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/dynamical_odes/index.html b/previews/PR305/tutorials/dynamical_odes/index.html index f4d18c327..58d7d0a74 100644 --- a/previews/PR305/tutorials/dynamical_odes/index.html +++ b/previews/PR305/tutorials/dynamical_odes/index.html @@ -19,13 +19,13 @@ tspan = (0.0, 100.0) prob = ODEProblem(Hénon_Heiles, [du0; u0], tspan) sol = solve(prob, EK1()); -plot(sol, idxs=(3, 4)) # where `idxs=(3,4)` is used to plot x agains yExample block output

Solving the second-order ODE directly

Instead of first transforming the problem, we can also solve it directly as a second-order ODE, by defining it as a SecondOrderODEProblem.

Note

The SecondOrderODEProblem type is not defined in ProbNumDiffEq.jl but is provided by SciMLBase.jl. For more information, check out the DifferentialEquations.jl documentation on Dynamical, Hamiltonian and 2nd Order ODE Problems.

function Hénon_Heiles2(ddu, du, u, p, t)
+plot(sol, idxs=(3, 4)) # where `idxs=(3,4)` is used to plot x agains y
Example block output

Solving the second-order ODE directly

Instead of first transforming the problem, we can also solve it directly as a second-order ODE, by defining it as a SecondOrderODEProblem.

Note

The SecondOrderODEProblem type is not defined in ProbNumDiffEq.jl but is provided by SciMLBase.jl. For more information, check out the DifferentialEquations.jl documentation on Dynamical, Hamiltonian and 2nd Order ODE Problems.

function Hénon_Heiles2(ddu, du, u, p, t)
     ddu[1] = -u[1] - 2 * u[1] * u[2]
     ddu[2] = u[2]^2 - u[2] - u[1]^2
 end
 prob2 = SecondOrderODEProblem(Hénon_Heiles2, du0, u0, tspan)
 sol2 = solve(prob2, EK1());
-plot(sol2, idxs=(3, 4))
Example block output

Benchmark: Solving second order ODEs is faster

Solving second-order ODEs is not just a matter of convenience - in fact, SciMLBase's SecondOrderODEProblem is neatly designed in such a way that all the classic solvers from OrdinaryDiffEq.jl can handle it by solving the corresponding first-order ODE. But, transforming the ODE to first order increases the dimensionality of the problem, and comes therefore at increased computational cost; this also motivates classic specialized solvers for second-order ODEs.

The probabilistic numerical solvers from ProbNumDiffEq.jl have the same internal state representation for first and second order ODEs; all that changes is the measurement model [1]. As a result, we can use the EK1 both for first and second order ODEs, but it automatically specializes on the latter to provide a 2x performance boost:

julia> @btime solve(prob, EK1(order=3), adaptive=false, dt=1e-2);
+plot(sol2, idxs=(3, 4))
Example block output

Benchmark: Solving second order ODEs is faster

Solving second-order ODEs is not just a matter of convenience - in fact, SciMLBase's SecondOrderODEProblem is neatly designed in such a way that all the classic solvers from OrdinaryDiffEq.jl can handle it by solving the corresponding first-order ODE. But, transforming the ODE to first order increases the dimensionality of the problem, and comes therefore at increased computational cost; this also motivates classic specialized solvers for second-order ODEs.

The probabilistic numerical solvers from ProbNumDiffEq.jl have the same internal state representation for first and second order ODEs; all that changes is the measurement model [1]. As a result, we can use the EK1 both for first and second order ODEs, but it automatically specializes on the latter to provide a 2x performance boost:

julia> @btime solve(prob, EK1(order=3), adaptive=false, dt=1e-2);
   766.312 ms (400362 allocations: 173.38 MiB)
 
 julia> @btime solve(prob2, EK1(order=4), adaptive=false, dt=1e-2);
@@ -37,7 +37,7 @@
 E(dx, dy, x, y) = PotentialEnergy(x, y) + KineticEnergy(dx, dy)
 E(u) = E(u...); # convenient shorthand
E (generic function with 2 methods)

Let's have a look at how the total energy changes over time when we numerically simulate the Hénon-Heiles model over a long period of time: Standard solve

longprob = remake(prob2, tspan=(0.0, 1e3))
 longsol = solve(longprob, EK1(smooth=false), dense=false)
-plot(longsol.t, E.(longsol.u))
Example block output

It visibly loses energy over time, from an initial 0.12967 to a final 0.12899. Let's fix this to get a physically more meaningful solution.

Energy preservation with the ManifoldUpdate callback

In the language of ODE filters, preserving energy over time amounts to just another measurement model [1]. The most convenient way of updating on this additional zero measurement with ProbNumDiffEq.jl is with the ManifoldUpdate callback.

Note

The ManifoldUpdate callback can be thought of a probabilistic counterpart to the ManifoldProjection callback provided by DiffEqCallbacks.jl.

To do so, first define a (vector-valued) residual function, here chosen to be the difference between the current energy and the initial energy, and build a ManifoldUpdate callback

residual(u) = [E(u) - E(du0..., u0...)]
+plot(longsol.t, E.(longsol.u))
Example block output

It visibly loses energy over time, from an initial 0.12967 to a final 0.12899. Let's fix this to get a physically more meaningful solution.

Energy preservation with the ManifoldUpdate callback

In the language of ODE filters, preserving energy over time amounts to just another measurement model [1]. The most convenient way of updating on this additional zero measurement with ProbNumDiffEq.jl is with the ManifoldUpdate callback.

Note

The ManifoldUpdate callback can be thought of a probabilistic counterpart to the ManifoldProjection callback provided by DiffEqCallbacks.jl.

To do so, first define a (vector-valued) residual function, here chosen to be the difference between the current energy and the initial energy, and build a ManifoldUpdate callback

residual(u) = [E(u) - E(du0..., u0...)]
 cb = ManifoldUpdate(residual)
DiscreteCallback{ProbNumDiffEq.var"#condition#133", ProbNumDiffEq.var"#affect!#134"{Int64, Float64, Float64, typeof(Main.residual)}, typeof(SciMLBase.INITIALIZE_DEFAULT), typeof(SciMLBase.FINALIZE_DEFAULT)}(ProbNumDiffEq.var"#condition#133"(), ProbNumDiffEq.var"#affect!#134"{Int64, Float64, Float64, typeof(Main.residual)}(100, 1.0e-25, 1.0e-15, Main.residual), SciMLBase.INITIALIZE_DEFAULT, SciMLBase.FINALIZE_DEFAULT, Bool[1, 1])

Then, solve the ODE with this callback

longsol_preserving = solve(longprob, EK1(smooth=false), dense=false, callback=cb)
 plot(longsol.t, E.(longsol.u))
-plot!(longsol_preserving.t, E.(longsol_preserving.u))
Example block output

Voilà! With the ManifoldUpdate callback we could preserve the energy over time and obtain a more truthful probabilistic numerical long-term simulation of the Hénon-Heiles model.

References

[1]
N. Bosch, F. Tronarp and P. Hennig. Pick-and-Mix Information Operators for Probabilistic ODE Solvers. In: Proceedings of The 25th International Conference on Artificial Intelligence and Statistics, Vol. 151 of Proceedings of Machine Learning Research, edited by G. Camps-Valls, F. J. Ruiz and I. Valera (PMLR, 28–30 Mar 2022); pp. 10015–10027.
+plot!(longsol_preserving.t, E.(longsol_preserving.u))Example block output

Voilà! With the ManifoldUpdate callback we could preserve the energy over time and obtain a more truthful probabilistic numerical long-term simulation of the Hénon-Heiles model.

References

[1]
N. Bosch, F. Tronarp and P. Hennig. Pick-and-Mix Information Operators for Probabilistic ODE Solvers. In: Proceedings of The 25th International Conference on Artificial Intelligence and Statistics, Vol. 151 of Proceedings of Machine Learning Research, edited by G. Camps-Valls, F. J. Ruiz and I. Valera (PMLR, 28–30 Mar 2022); pp. 10015–10027.
diff --git a/previews/PR305/tutorials/exponential_integrators/272f6aaa.svg b/previews/PR305/tutorials/exponential_integrators/334d650f.svg similarity index 98% rename from previews/PR305/tutorials/exponential_integrators/272f6aaa.svg rename to previews/PR305/tutorials/exponential_integrators/334d650f.svg index fe8f0f3fd..37cbfaf58 100644 --- a/previews/PR305/tutorials/exponential_integrators/272f6aaa.svg +++ b/previews/PR305/tutorials/exponential_integrators/334d650f.svg @@ -1,63 +1,63 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/exponential_integrators/80e2fab0.svg b/previews/PR305/tutorials/exponential_integrators/8c59d23e.svg similarity index 98% rename from previews/PR305/tutorials/exponential_integrators/80e2fab0.svg rename to previews/PR305/tutorials/exponential_integrators/8c59d23e.svg index 19c725830..3691824b6 100644 --- a/previews/PR305/tutorials/exponential_integrators/80e2fab0.svg +++ b/previews/PR305/tutorials/exponential_integrators/8c59d23e.svg @@ -1,65 +1,65 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/exponential_integrators/468a6f1b.svg b/previews/PR305/tutorials/exponential_integrators/9f557e9c.svg similarity index 99% rename from previews/PR305/tutorials/exponential_integrators/468a6f1b.svg rename to previews/PR305/tutorials/exponential_integrators/9f557e9c.svg index 61fccdca7..71c250f59 100644 --- a/previews/PR305/tutorials/exponential_integrators/468a6f1b.svg +++ b/previews/PR305/tutorials/exponential_integrators/9f557e9c.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/exponential_integrators/2c906e49.svg b/previews/PR305/tutorials/exponential_integrators/d4bf17d7.svg similarity index 99% rename from previews/PR305/tutorials/exponential_integrators/2c906e49.svg rename to previews/PR305/tutorials/exponential_integrators/d4bf17d7.svg index 7059cc798..1646c7f0b 100644 --- a/previews/PR305/tutorials/exponential_integrators/2c906e49.svg +++ b/previews/PR305/tutorials/exponential_integrators/d4bf17d7.svg @@ -1,51 +1,51 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/exponential_integrators/index.html b/previews/PR305/tutorials/exponential_integrators/index.html index 6b6c4c26d..a7f764b8b 100644 --- a/previews/PR305/tutorials/exponential_integrators/index.html +++ b/previews/PR305/tutorials/exponential_integrators/index.html @@ -12,7 +12,7 @@ prob = ODEProblem(f, u0, tspan) ref = solve(prob, EK1(), abstol=1e-10, reltol=1e-10) -plot(ref, color=:black, linestyle=:dash, label="Reference")Example block output

But for fixed (large) step sizes this ODE is more challenging: The explicit EK0 method oscillates and diverges due to the stiffness of the ODE, and the semi-implicit EK1 method is stable but the solution is not very accurate.

STEPSIZE = 4
+plot(ref, color=:black, linestyle=:dash, label="Reference")
Example block output

But for fixed (large) step sizes this ODE is more challenging: The explicit EK0 method oscillates and diverges due to the stiffness of the ODE, and the semi-implicit EK1 method is stable but the solution is not very accurate.

STEPSIZE = 4
 DM = FixedDiffusion() # recommended for fixed steps
 
 # we don't smooth the EK0 here to show the oscillations more clearly
@@ -22,14 +22,14 @@
 plot(ylims=(0.3, 1.05))
 plot!(ref, color=:black, linestyle=:dash, label="Reference")
 plot!(sol0, denseplot=false, marker=:o, markersize=2, label="EK0", color=1)
-plot!(sol1, denseplot=false, marker=:o, markersize=2, label="EK1", color=2)
Example block output

Probabilistic exponential integrators leverage the semi-linearity of the ODE to compute more accurate solutions for the same fixed step size. You can use either the ExpEK method and provide the linear part (with the keyword argument L), or the RosenbrockExpEK to automatically linearize along the mean of the numerical solution:

sol_exp = solve(prob, ExpEK(L=-1, diffusionmodel=DM), adaptive=false, dt=STEPSIZE)
+plot!(sol1, denseplot=false, marker=:o, markersize=2, label="EK1", color=2)
Example block output

Probabilistic exponential integrators leverage the semi-linearity of the ODE to compute more accurate solutions for the same fixed step size. You can use either the ExpEK method and provide the linear part (with the keyword argument L), or the RosenbrockExpEK to automatically linearize along the mean of the numerical solution:

sol_exp = solve(prob, ExpEK(L=-1, diffusionmodel=DM), adaptive=false, dt=STEPSIZE)
 sol_ros = solve(prob, RosenbrockExpEK(diffusionmodel=DM), adaptive=false, dt=STEPSIZE)
 
 plot(ylims=(0.3, 1.05))
 plot!(ref, color=:black, linestyle=:dash, label="Reference")
 plot!(sol_exp, denseplot=false, marker=:o, markersize=2, label="ExpEK", color=3)
-plot!(sol_ros, denseplot=false, marker=:o, markersize=2, label="RosenbrockExpEK", color=4)
Example block output

The solutions are indeed much more accurate than those of the standard EK1, for the same fixed step size!

Background: Integrated Ornstein-Uhlenbeck priors

Probabilistic exponential integrators "solve the linear part exactly" by including it into the prior model of the solver. Namely, the solver chooses a (q-times) integrated Ornstein-Uhlenbeck prior with rate parameter equal to the linearity. The ExpEK solver is just a short-hand for an EK0 with appropriate prior:

julia> ExpEK(order=3, L=-1) == EK0(prior=IOUP(3, -1))true

Similarly, the RosenbrockExpEK solver is also just a short-hand:

julia> RosenbrockExpEK(order=3) == EK1(prior=IOUP(3, update_rate_parameter=true))true

This means that you can also construct other probabilistic exponential integrators by hand! In this example the EK1 with IOUP prior with rate parameter -1 performs extremely well:

sol_expek1 = solve(prob, EK1(prior=IOUP(3, -1), diffusionmodel=DM), adaptive=false, dt=STEPSIZE)
+plot!(sol_ros, denseplot=false, marker=:o, markersize=2, label="RosenbrockExpEK", color=4)
Example block output

The solutions are indeed much more accurate than those of the standard EK1, for the same fixed step size!

Background: Integrated Ornstein-Uhlenbeck priors

Probabilistic exponential integrators "solve the linear part exactly" by including it into the prior model of the solver. Namely, the solver chooses a (q-times) integrated Ornstein-Uhlenbeck prior with rate parameter equal to the linearity. The ExpEK solver is just a short-hand for an EK0 with appropriate prior:

julia> ExpEK(order=3, L=-1) == EK0(prior=IOUP(3, -1))true

Similarly, the RosenbrockExpEK solver is also just a short-hand:

julia> RosenbrockExpEK(order=3) == EK1(prior=IOUP(3, update_rate_parameter=true))true

This means that you can also construct other probabilistic exponential integrators by hand! In this example the EK1 with IOUP prior with rate parameter -1 performs extremely well:

sol_expek1 = solve(prob, EK1(prior=IOUP(3, -1), diffusionmodel=DM), adaptive=false, dt=STEPSIZE)
 
 plot(ylims=(0.3, 1.05))
 plot!(ref, color=:black, linestyle=:dash, label="Reference")
-plot!(sol_expek1, denseplot=false, marker=:o, markersize=2, label="EK1 + IOUP")
Example block output

References

[2]
N. Bosch, P. Hennig and F. Tronarp. Probabilistic Exponential Integrators. In: Thirty-seventh Conference on Neural Information Processing Systems (2023).
+plot!(sol_expek1, denseplot=false, marker=:o, markersize=2, label="EK1 + IOUP")Example block output

References

[2]
N. Bosch, P. Hennig and F. Tronarp. Probabilistic Exponential Integrators. In: Thirty-seventh Conference on Neural Information Processing Systems (2023).
diff --git a/previews/PR305/tutorials/getting_started/19a76b72.svg b/previews/PR305/tutorials/getting_started/9c4d2956.svg similarity index 91% rename from previews/PR305/tutorials/getting_started/19a76b72.svg rename to previews/PR305/tutorials/getting_started/9c4d2956.svg index 74e23eb2b..70f719d27 100644 --- a/previews/PR305/tutorials/getting_started/19a76b72.svg +++ b/previews/PR305/tutorials/getting_started/9c4d2956.svg @@ -1,54 +1,54 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/getting_started/949a7f59.svg b/previews/PR305/tutorials/getting_started/9da6d436.svg similarity index 98% rename from previews/PR305/tutorials/getting_started/949a7f59.svg rename to previews/PR305/tutorials/getting_started/9da6d436.svg index caf4ebd79..eb8397137 100644 --- a/previews/PR305/tutorials/getting_started/949a7f59.svg +++ b/previews/PR305/tutorials/getting_started/9da6d436.svg @@ -1,50 +1,50 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/getting_started/0c05c7cd.svg b/previews/PR305/tutorials/getting_started/c0dbcbaa.svg similarity index 98% rename from previews/PR305/tutorials/getting_started/0c05c7cd.svg rename to previews/PR305/tutorials/getting_started/c0dbcbaa.svg index 31c7b665d..4fc2841a6 100644 --- a/previews/PR305/tutorials/getting_started/0c05c7cd.svg +++ b/previews/PR305/tutorials/getting_started/c0dbcbaa.svg @@ -1,50 +1,50 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/getting_started/index.html b/previews/PR305/tutorials/getting_started/index.html index 9a38b2998..7872d612b 100644 --- a/previews/PR305/tutorials/getting_started/index.html +++ b/previews/PR305/tutorials/getting_started/index.html @@ -15,7 +15,7 @@ prob = ODEProblem(fitz, u0, tspan, p) sol = solve(prob, EK1()) -plot(sol)Example block output

Step 1: Define the problem

First, import ProbNumDiffEq.jl

using ProbNumDiffEq

Then, set up the ODEProblem exactly as you would in DifferentialEquations.jl. Define the vector field

function fitz(du, u, p, t)
+plot(sol)
Example block output

Step 1: Define the problem

First, import ProbNumDiffEq.jl

using ProbNumDiffEq

Then, set up the ODEProblem exactly as you would in DifferentialEquations.jl. Define the vector field

function fitz(du, u, p, t)
     a, b, c = p
     du[1] = c * (u[1] - u[1]^3 / 3 + u[2])
     du[2] = -(1 / c) * (u[1] - a - b * u[2])
@@ -66,13 +66,13 @@
  [2.0350861534147566, 0.7169394922557]
  [2.0210436519484087, 0.6717007174964914]
  [2.0104405118668827, 0.6383145073764079]

That's it! we just computed a probabilistic numerical ODE solution!

Step 3: Analyze the solution

Let's plot the result with Plots.jl.

using Plots
-plot(sol)
Example block output

Looks good! Looks like the EK1 managed to solve the Fitzhugh-Nagumo problem quite well.

Tip

To learn more about plotting ODE solutions, check out the plotting tutorial for DifferentialEquations.jl + Plots.jl provided here. Most of that works exactly as expected with ProbNumDiffEq.jl.

Plot the probabilistic error estimates

The plot above looks like a standard ODE solution – but it's not! The numerical errors are just so small that we can't see them in the plot, and the probabilistic error estimates are too. We can visualize them by plotting the errors and error estimates directly:

using OrdinaryDiffEq, Statistics
+plot(sol)
Example block output

Looks good! Looks like the EK1 managed to solve the Fitzhugh-Nagumo problem quite well.

Tip

To learn more about plotting ODE solutions, check out the plotting tutorial for DifferentialEquations.jl + Plots.jl provided here. Most of that works exactly as expected with ProbNumDiffEq.jl.

Plot the probabilistic error estimates

The plot above looks like a standard ODE solution – but it's not! The numerical errors are just so small that we can't see them in the plot, and the probabilistic error estimates are too. We can visualize them by plotting the errors and error estimates directly:

using OrdinaryDiffEq, Statistics
 reference = solve(prob, Vern9(), abstol=1e-9, reltol=1e-9, saveat=sol.t)
 errors = reduce(hcat, mean.(sol.pu) .- reference.u)'
 error_estimates = reduce(hcat, std.(sol.pu))'
 plot(sol.t, errors, label="error", color=[1 2], xlabel="t", ylabel="err")
 plot!(sol.t, zero(errors), ribbon=3error_estimates, label="error estimate",
-      color=[1 2], alpha=0.2)
Example block output

More about the ProbabilisticODESolution

The solution object returned by ProbNumDiffEq.jl mostly behaves just like any other ODESolution in DifferentialEquations.jl – with some added uncertainties and related functionality on top. The ProbabilisticODESolution can be indexed with

julia> sol.u[1]2-element Vector{Float64}:
+      color=[1 2], alpha=0.2)
Example block output

More about the ProbabilisticODESolution

The solution object returned by ProbNumDiffEq.jl mostly behaves just like any other ODESolution in DifferentialEquations.jl – with some added uncertainties and related functionality on top. The ProbabilisticODESolution can be indexed with

julia> sol.u[1]2-element Vector{Float64}:
  -1.0
   1.0
julia> sol.u[end]2-element Vector{Float64}: 2.0104405118668827 @@ -91,4 +91,4 @@ 2.8014003609822313e-6 2.7505533924668052e-6

Dense output

Probabilistic numerical ODE solvers approximate the posterior distribution

\[p \Big( y(t) ~\big|~ y(0) = y_0, \{ \dot{y}(t_i) = f_\theta(y(t_i), t_i) \} \Big),\]

which describes a posterior not just for the discrete steps but for any $t$ in the continuous space $t \in [0, T]$; in classic ODE solvers, this is also known as "interpolation" or "dense output". The probabilistic solutions returned by our solvers can be interpolated as usual by treating them as functions, but they return Gaussian distributions

julia> sol(0.45)Gaussian{Vector{Float64},PSDMatrix{Float64, Matrix{Float64}}}([-0.2773821283086794, 1.1675659430627088], 2x2 PSDMatrix{Float64, Matrix{Float64}}; R=[-3.2083544077891136e-5 -4.7899698453730076e-6; 0.0 -2.4206415622162586e-5; 0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0; 0.0 0.0])
julia> mean(sol(0.45))2-element Vector{Float64}: -0.2773821283086794 - 1.1675659430627088

Next steps

Check out one of the other tutorials:

+ 1.1675659430627088

Next steps

Check out one of the other tutorials:

diff --git a/previews/PR305/tutorials/ode_parameter_inference/1921a277.svg b/previews/PR305/tutorials/ode_parameter_inference/1921a277.svg new file mode 100644 index 000000000..6d63de9d0 --- /dev/null +++ b/previews/PR305/tutorials/ode_parameter_inference/1921a277.svg @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/ode_parameter_inference/45aa2674.svg b/previews/PR305/tutorials/ode_parameter_inference/45aa2674.svg new file mode 100644 index 000000000..dbfc61de2 --- /dev/null +++ b/previews/PR305/tutorials/ode_parameter_inference/45aa2674.svg @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/ode_parameter_inference/49c9d55f.svg b/previews/PR305/tutorials/ode_parameter_inference/49c9d55f.svg new file mode 100644 index 000000000..862f21a8c --- /dev/null +++ b/previews/PR305/tutorials/ode_parameter_inference/49c9d55f.svg @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR305/tutorials/ode_parameter_inference/6a824939.svg b/previews/PR305/tutorials/ode_parameter_inference/6a824939.svg deleted file mode 100644 index 26f44ca74..000000000 --- a/previews/PR305/tutorials/ode_parameter_inference/6a824939.svg +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/previews/PR305/tutorials/ode_parameter_inference/739bac36.svg b/previews/PR305/tutorials/ode_parameter_inference/739bac36.svg deleted file mode 100644 index ceb1b9c98..000000000 --- a/previews/PR305/tutorials/ode_parameter_inference/739bac36.svg +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/previews/PR305/tutorials/ode_parameter_inference/e794f0c2.svg b/previews/PR305/tutorials/ode_parameter_inference/e794f0c2.svg deleted file mode 100644 index a65f541a8..000000000 --- a/previews/PR305/tutorials/ode_parameter_inference/e794f0c2.svg +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/previews/PR305/tutorials/ode_parameter_inference/index.html b/previews/PR305/tutorials/ode_parameter_inference/index.html index 07f1f33db..ad9f66308 100644 --- a/previews/PR305/tutorials/ode_parameter_inference/index.html +++ b/previews/PR305/tutorials/ode_parameter_inference/index.html @@ -26,18 +26,18 @@ odedata = [H*true_sol(t) .+ σ * randn() for t in times] plot(true_sol, color=:black, linestyle=:dash, label=["True Solution" ""]) -scatter!(times, stack(odedata)', color=1, label=["Noisy Data" ""])Example block output

Our goal is then to recover the true parameter p (and thus also the true trajectory plotted above) the noisy data.

Computing the negative log-likelihood

To do parameter inference - be it maximum-likelihod, maximum a posteriori, or full Bayesian inference with MCMC - we need to evaluate the likelihood of given a parameter estimate $\theta_\text{est}$, which corresponds to the probability of the data under the trajectory returned by the ODE solver

θ_est = (0.1, 0.1, 2.0)
+scatter!(times, stack(odedata)',  color=1, label=["Noisy Data" ""])
Example block output

Our goal is then to recover the true parameter p (and thus also the true trajectory plotted above) the noisy data.

Computing the negative log-likelihood

To do parameter inference - be it maximum-likelihod, maximum a posteriori, or full Bayesian inference with MCMC - we need to evaluate the likelihood of given a parameter estimate $\theta_\text{est}$, which corresponds to the probability of the data under the trajectory returned by the ODE solver

θ_est = (0.1, 0.1, 2.0)
 prob = remake(true_prob, p=θ_est)
 plot(true_sol, color=:black, linestyle=:dash, label=["True Solution" ""])
 scatter!(times, stack(odedata)', color=1, label=["Noisy Data" ""])
 sol = solve(prob, EK1(), adaptive=false, dt=1e-1)
-plot!(sol, color=2, label=["Numerical solution for θ_est" ""])
Example block output

This quantity can be computed in multiple ways; see Data Likelihoods. Here we use ProbNumDiffEq.DataLikelihoods.fenrir_data_loglik:

using ProbNumDiffEq.DataLikelihoods
+plot!(sol, color=2, label=["Numerical solution for θ_est" ""])
Example block output

This quantity can be computed in multiple ways; see Data Likelihoods. Here we use ProbNumDiffEq.DataLikelihoods.fenrir_data_loglik:

using ProbNumDiffEq.DataLikelihoods
 
 data = (t=times, u=odedata)
 nll = -fenrir_data_loglik(
     prob, EK1(smooth=true);
     data, observation_noise_cov=σ^2, observation_matrix=H,
-    adaptive=false, dt=1e-1)
6443.086129426544

This is the negative marginal log-likelihood of the parameter θ_est. You can use it as any other NLL: Optimize it to compute maximum-likelihood estimates or MAPs, or plug it into MCMC to sample from the posterior. In our paper [3] we compute MLEs by pairing Fenrir with Optimization.jl and ForwardDiff.jl. Let's quickly explore how to do this next.

Maximum-likelihood parameter inference

To compute a maximum-likelihood estimate (MLE), we just need to maximize $\theta \to p(\mathcal{D} \mid \theta)$ - that is, minimize the nll from above. We use Optimization.jl for this. First, define a loss function and create an OptimizationProblem

using Optimization, OptimizationOptimJL
+    adaptive=false, dt=1e-1)
6551.824482505471

This is the negative marginal log-likelihood of the parameter θ_est. You can use it as any other NLL: Optimize it to compute maximum-likelihood estimates or MAPs, or plug it into MCMC to sample from the posterior. In our paper [3] we compute MLEs by pairing Fenrir with Optimization.jl and ForwardDiff.jl. Let's quickly explore how to do this next.

Maximum-likelihood parameter inference

To compute a maximum-likelihood estimate (MLE), we just need to maximize $\theta \to p(\mathcal{D} \mid \theta)$ - that is, minimize the nll from above. We use Optimization.jl for this. First, define a loss function and create an OptimizationProblem

using Optimization, OptimizationOptimJL
 
 function loss(x, _)
     ode_params = x[begin:end-1]
@@ -61,9 +61,9 @@
  2.0
  1.0

Then, just solve it! Here we use LBFGS:

optsol = solve(optprob, LBFGS())
 p_mle = optsol.u[1:3]
3-element Vector{Float64}:
- 0.20854725866142923
- 0.16296337149694176
- 3.010570656886079

Success! The computed MLE is quite close to the true parameter which we used to generate the data. As a final step, let's plot the true solution, the data, and the result of the MLE:

plot(true_sol, color=:black, linestyle=:dash, label=["True Solution" ""])
+ 0.2035004549304119
+ 0.13923686227576784
+ 3.03340138513428

Success! The computed MLE is quite close to the true parameter which we used to generate the data. As a final step, let's plot the true solution, the data, and the result of the MLE:

plot(true_sol, color=:black, linestyle=:dash, label=["True Solution" ""])
 scatter!(times, stack(odedata)', color=1, label=["Noisy Data" ""])
 mle_sol = solve(remake(true_prob, p=p_mle), EK1())
-plot!(mle_sol, color=3, label=["MLE-parameter Solution" ""])
Example block output

Looks good!

API Documentation

For more details, see the API documentation of ProbNumDiffEq.DataLikelihoods at Data Likelihoods.

References

[3]
F. Tronarp, N. Bosch and P. Hennig. Fenrir: Physics-Enhanced Regression for Initial Value Problems. In: Proceedings of the 39th International Conference on Machine Learning, Vol. 162 of Proceedings of Machine Learning Research, edited by K. Chaudhuri, S. Jegelka, L. Song, C. Szepesvari, G. Niu and S. Sabato (PMLR, 17–23 Jul 2022); pp. 21776–21794.
[10]
+plot!(mle_sol, color=3, label=["MLE-parameter Solution" ""])Example block output

Looks good!

API Documentation

For more details, see the API documentation of ProbNumDiffEq.DataLikelihoods at Data Likelihoods.

References

[3]
F. Tronarp, N. Bosch and P. Hennig. Fenrir: Physics-Enhanced Regression for Initial Value Problems. In: Proceedings of the 39th International Conference on Machine Learning, Vol. 162 of Proceedings of Machine Learning Research, edited by K. Chaudhuri, S. Jegelka, L. Song, C. Szepesvari, G. Niu and S. Sabato (PMLR, 17–23 Jul 2022); pp. 21776–21794.
[10]