codes

Codes for all examples in the book "A Toolbox for Digital Twins". When multi-language versions are available, they are indicated by a * after the example description.

Code examples for Chapter 1.


Code examples for Chapter 3.


Availability of multi-language versions is indicated by a *.

nonlinear, linear and difference equations

  • Example 3.4 solution of a nonlinear equation by various methods.*
  • Example 3.11 solution of an ill-conditioned linear system.*
  • Example 3.15 cobweb plot of a difference equation.*

ode

  • Example 3.25 solve an unstable ordinary differential equation by different methods.*
  • Example 3.28 – see Example 3.25.

finite difference methods

  • Example 3.29 solution of a transport equation by different methods.*
  • Example 3.30 Laplace equation with Neumann boundary condition.*
  • Example 3.31 2D Poisson equation in L-shaped geometry.
  • Example 3.32 2D Poisson equation for electrostatics with different solvers.
  • Example 3.33 1D heat equation with Crank-Nicolson scheme.
  • Example 3.34 1D heat equation with explicit and implicit schemes.
  • Example 3.35 2D wave equation with absorbing boundary conditions.
  • Example 3.36 2D wave equation with very efficient implementation.

finite element methods

  • Example 3.39 2D elctrostatics with Dirichlet conditions.
  • Example 3.40 2D Poisson equation convergence analysis.
  • Example 3.41 2D Poisson equation with Dirichlet and Neumann conditions.
  • Example 3.43 nonlinear elliptic equation with Picard iteration.
  • Example 3.44 nonlinear elliptic equation with Newton iteration.
  • Example 3.45 nonlinear elliptic equation with additive term.

stochastic simulation (monte-carlo methods)

  • Example 3.46 Monte-Carlo integration.*
  • Example 3.47 Monte-Carlo integration–convergence study.
  • Example 3.48 importance sampling for variance reduction.
  • Example 3.49 rejection sampling for variance reduction.
  • Example 3.56 Metropolis-Hasting MCMC for computing a posterior.
  • Example 3.57 – see Example 3.56.
  • Example 3.58 Simple MCMC for a Gaussian posterior.

stochastic differential equations

Code examples for Chapter 4.


Code examples for Chapter 5.


supervised learning

unsupervised learning

cross-validation and tuning

Code examples for Chapter 6.


  • Example 6.2 underitting and overfitting
  • Example 6.3 - see Example 6.2

Code examples for Chapter 8.


Code examples for Chapter 9.


  • Example 9.8 Gaussian state space model.
  • Example 9.12 Kalman filter for Gaussian state space model.
  • Example 9.14 extended Kalman filter for noisy pendulum.
  • Example 9.18 unscented Kalman filter for 2D navigation.
  • Example 9.21 ensemble Kalman filter for Lorenz-63 chaotic system.
  • Example 9.22 ensemble Kalman filter for Kuramoto-Sivashinsky turbulent system.

Code examples for Chapter 10.


Code examples for Chapter 11.


Bayesian estimation

  • Example 11.5 Bayesian inference for binomial random variable (influence of priors).
  • Example 11.7 Bayesian inference for binomial random variable with beta conjugate priors.
  • Example 11.8 Bayesian inference for epidemics.

Bayesian regression

  • Example 11.10 Bayesian inference with Gaussian products.
  • Example 11.12 Bayesian inference of a mean for air quality data.
  • Example 11.13 Bayesian inference for a multivariate Gaussian (linear regression).
  • Example 11.14 Bayesian inference for parameters of a noisy pendulum.
  • Example 11.15 Bayesian regression and model reduction for diabetes data.
  • Example 11.17 Gaussian process regression for a sine function.

Bayesian filters

  • Example 11.18 Bayesian sequential regression for a multivariate Gaussian.
  • Example 11.19 Bayesian sequential estimation of 2d coordinates.

Bayesian inverse problems

Bayesian optimization

probabilistic programming

Code examples for Chapter 12.