Skip to content

Priors

A prior is a Gauss–Markov process over the solution and its first q derivatives. It encodes the smoothness that is assumed before the ODE enters. See How to choose for picking one.

Prior Process Key parameters
IWP q-times integrated Wiener process (the default) q (smoothness order), d (dimension), Xi (structural scale)
MaternPrior Matern process of smoothness nu = q + 1/2, unit variance q (smoothness order), d (dimension), length_scale (the textbook l of Rasmussen & Williams 2006, eq. 4.14; SDE rate sqrt(2q+1) / l), Xi (structural scale)
IOUPPrior integrated Ornstein–Uhlenbeck process, whose highest derivative follows dY^(q) = R Y^(q) dt + dW q, d, rate (scalar, length-d vector, or d × d matrix), Xi
JointPrior a state block stacked with a hidden block exposes E0_x, E0_hidden for joint state–parameter models
PrecondIWP, PrecondMaternPrior the same processes, computed in preconditioned coordinates better conditioning at high q / small h

q sets the method's order of accuracy; Xi (together with the calibrated sigma^2) sets the size of the uncertainty. Initialize the state from x0 with taylor_mode_initialization(vf, x0, q) (which returns the Taylor-mode mean and a zero/Dirac initial covariance). Symbols are defined in Notation.

Every prior exposes the discrete-time transition A(h), drift b(h), process noise Q(h) and its upper-triangular square root Q_sqr(h) (Q = Q_sqr.T @ Q_sqr), all in the original coordinates. A filter step consumes transition(h): the same matrices, or for a preconditioned prior their better-conditioned form in rescaled coordinates together with the rescaling. For IWP / PrecondIWP this is a closed form that never factorizes the dense, ill-conditioned Q(h). For MaternPrior / PrecondMaternPrior / IOUPPrior it is a square-root matrix-fraction decomposition, which also never forms the dense Q(h). Prefer Q_sqr(h) over Q(h) in downstream code, because at high q the dense Q(h) loses positive-definiteness while the square-root factor stays accurate.

Priors

IWP

IWP(q: int, d: int, Xi: ArrayLike | None = None)

Bases: BasePrior

Integrated Wiener process prior: the default choice.

The q-th derivative of the solution is Brownian motion, so between grid points the prior behaves like a polynomial of degree q whose top coefficient is driven by noise. A(h) and the square-root process noise Q_sqr(h) are closed-form.

Parameters:

Name Type Description Default
q int

Number of modelled derivatives (the order of the method).

required
d int

Dimension of the solution x.

required
Xi ArrayLike | None

Component-correlation matrix of the driving noise, shape [d, d]; defaults to the identity.

None

A

A(h: ArrayLike) -> Array

Transition matrix kron(A_scalar(h), I_d).

Q_sqr

Q_sqr(h: ArrayLike) -> Array

Closed-form kron(Q_bar_sqr @ T(h), chol(Xi)).

Q(h) = T(h) Q_bar T(h) with the diagonal T(h) and the constant Hilbert-type Q_bar, so the step size enters only through the well-behaved T(h); the ill-conditioned dense Q(h) is never formed.

MaternPrior

MaternPrior(
    q: int,
    d: int,
    length_scale: ArrayLike,
    Xi: ArrayLike | None = None,
    *,
    n_quad: int = QUAD_NODES,
)

Bases: BasePrior

Matern Gauss-Markov prior: a stationary process with a length scale.

Each of the d components is a Matern process of smoothness nu = q + 1/2 with unit marginal variance; Xi correlates them and sets their scale, Q(h) = kron(Q_scalar(h), Xi). Unlike the IWP it reverts to zero over the length scale. The square-root process noise is a square-root matrix-fraction decomposition (Bosch, Hennig & Tronarp 2023), which stays accurate up to the float64 order ceiling (q ~ 18).

The length scale l is the textbook one (Rasmussen & Williams 2006, Sec. 4.2.1, eq. 4.14): the correlation of a component at lag tau is the Matern kernel in r = sqrt(2 nu) tau / l, i.e. exp(-tau / l) for q = 0, (1 + r) exp(-r) for q = 1 and (1 + r + r^2 / 3) exp(-r) for q = 2 (eq. 4.17). The SDE rate is lambda = sqrt(2 nu) / l (Saerkkae, Solin & Hartikainen 2013, Example 1).

Parameters:

Name Type Description Default
q int

Smoothness order (nu = q + 1/2).

required
d int

Dimension of the solution.

required
length_scale ArrayLike

Length scale l of the process, in the textbook convention above (SDE rate lambda = sqrt(2q+1) / l).

required
Xi ArrayLike | None

Component-correlation matrix, shape [d, d]; defaults to the identity. Per-component calibration requires it diagonal.

None
n_quad int

Gauss-Legendre nodes of the square-root decomposition (must exceed q; the default is robust to the order ceiling).

QUAD_NODES

A

A(h: ArrayLike) -> Array

Transition matrix kron(expm(F h), I_d).

Q_sqr

Q_sqr(h: ArrayLike) -> Array

kron(R(h), chol(Xi)) with R the scalar noise factor.

stationary_cov_sqr

stationary_cov_sqr() -> Array

Upper-triangular square root of the stationary covariance.

The covariance of [u, u', ..., u^(q)] under the stationary law, for all d components: kron(P_scalar, Xi), whose top-left entry is Xi (unit marginal variance per component). Computed in normalized coordinates, where it does not depend on the length scale, so it is finite at short length scales and differentiable in length_scale and Xi.

IOUPPrior

IOUPPrior(
    q: int,
    d: int,
    rate: ArrayLike,
    Xi: ArrayLike | None = None,
    *,
    n_quad: int = QUAD_NODES,
)

Bases: BasePrior

Integrated Ornstein-Uhlenbeck Process prior (probabilistic exponential integrator).

Like IWP, IOUP is a q-times integrated Gauss-Markov prior, but its highest derivative follows linear (Ornstein-Uhlenbeck) dynamics dY^(q) = R Y^(q) dt + dW with a rate R. Choosing R to be (part of) the ODE's linear dynamics bakes those dynamics into the prior, turning the solver into a probabilistic exponential integrator: the prior mean integrates the linear part exactly, so the filter only has to correct the nonlinear remainder (Bosch, Hennig & Tronarp, NeurIPS 2023). IWP is the R = 0 special case.

IOUP is a drop-in prior: the measurement model (the standard ODE information operator on the full vector field) and the filter/smoother recursion are unchanged. For a constant rate, A(h) = exp(F h) and the square-root process noise Q_sqr(h) are computed per step size like any other prior, the latter via the same square-root matrix-fraction decomposition as MaternPrior (_sqr_noise_via_quadrature), never forming the dense Q(h).

Note

The diffusion fit by calibration="dynamic"/"diagonal" is estimated on the IOUP residual, which is the nonlinear remainder and not the full vector field as under IWP. The calibrated diffusion therefore has a different scale than under IWP, which matters only when a calibration is compared or transferred across priors. A full matrix rate couples the output dimensions, so A/Q are not Kronecker-separable (a dense (q+1)*d matrix exponential); scalar/diagonal rates are separable in principle but are assembled densely here for a single uniform implementation.

Parameters:

Name Type Description Default
q int

Number of derivatives (smoothness order), as for IWP.

required
d int

State dimension.

required
rate ArrayLike

OU rate of the highest derivative: a scalar (uniform), a length-d vector (a diagonal rate per dimension), or a d x d matrix that couples the dimensions (e.g. the linear part or a reference Jacobian of the ODE).

required
Xi ArrayLike | None

Optional component-correlation matrix of the driving noise (shape [d, d]).

None
n_quad int

Number of Gauss-Legendre nodes for the square-root matrix-fraction decomposition used by Q_sqr.

QUAD_NODES

A

A(h: ArrayLike) -> Array

Transition matrix expm(F h).

Q_sqr

Q_sqr(h: ArrayLike) -> Array

Square-root process noise by the square-root matrix-fraction decomposition.

JointPrior

JointPrior(prior_x: BasePrior, prior_u: BasePrior)

Bases: BasePrior

Joint prior of a state x and a hidden input u, independent a priori.

The state is [x-block, u-block], each derivative-major, and every matrix is block-diagonal. The hidden input can be a latent force or an unknown parameter that enters the ODE (see ODEInformationWithHidden) and evolves by its own prior. The diffusion calibration scales the state block only (Schmidt et al. 2021).

Either block may be preconditioned (PrecondIWP, PrecondMaternPrior): the joint transition then carries that block's preconditioner and the identity for a plain one.

Selectors

E0: [x, u], shape [d_x + d_u, D]. E0_x: x alone, shape [d_x, D] (the ODE's E0). E0_hidden: u alone, shape [d_u, D]. E1, E2: x' and x'' (E2 is None if q_x < 2).

Parameters:

Name Type Description Default
prior_x BasePrior

Prior of the state.

required
prior_u BasePrior

Prior of the hidden input.

required

E0 property

E0: Array

Selector of [x, u], shape [d_x + d_u, D].

E0_hidden property

E0_hidden: Array

Selector of the hidden input u.

E0_state property

E0_state: Array

Selector of x: the adaptive error estimate ignores the input.

E0_x property

E0_x: Array

Selector of x alone: the E0 of the ODE information.

E1 property

E1: Array

Selector of x', shape [d_x, D].

E2 property

E2: Array | None

Selector of x'', shape [d_x, D], or None if q_x < 2.

d property

d: int

Dimension of [x, u].

q property

q: int

The state prior's order: it sets the convergence order of the solver.

state_dim property

state_dim: int

Dimension of the joint state, D_x + D_u.

xi property

xi: Array

blkdiag(Xi_x, Xi_u): the two processes are independent.

xi_state property

xi_state: Array

The state prior's Xi; the input's may be arbitrary.

xi_state_diagonal property

xi_state_diagonal: bool | None

Whether the state prior's Xi was diagonal at construction.

A

A(h: ArrayLike) -> Array

Block-diagonal of the blocks' transition matrices.

Q_sqr

Q_sqr(h: ArrayLike) -> Array

Block-diagonal of the blocks' square roots (Q is block-diagonal).

b

b(h: ArrayLike) -> Array

The blocks' drifts, stacked.

transition

transition(h: ArrayLike) -> Transition

Block-diagonal transition of the two sub-priors.

If either sub-prior is preconditioned, the joint transition is in the coordinates of both blocks' preconditioners (the identity for a plain block).

Preconditioned priors

These are the same processes, computed in coordinates rescaled by the step size, x = T(h) @ x_bar. The rescaling is a change of variables inside each filter step, so the results are identical up to round-off and every solver accepts these priors. A JointPrior may combine plain and preconditioned blocks.

PrecondIWP

PrecondIWP(q: int, d: int, Xi: ArrayLike | None = None)

Bases: IWP

IWP computed in step-size-preconditioned coordinates.

The process is the same as IWP, and A(h), Q(h) and Q_sqr(h) are those of IWP. The filters, however, compute each step in the coordinates x_bar = T(h)^-1 x, in which the transition and the process noise do not depend on the step size. The whole dependence on h sits in the diagonal T(h) (Kraemer & Hennig 2020). Results are reported in the original coordinates.

Parameters:

Name Type Description Default
q int

Number of modeled derivatives (the order of the method).

required
d int

Dimension of the solution x.

required
Xi ArrayLike | None

Component-correlation matrix of the driving noise, shape [d, d]; defaults to the identity.

None

T

T(h: ArrayLike) -> Array

The diagonal preconditioner T(h) (x = T x_bar), [D, D].

transition

transition(h: ArrayLike) -> Transition

Step-size independent A and Q_sqr with the preconditioner T(h).

PrecondMaternPrior

PrecondMaternPrior(
    q: int,
    d: int,
    length_scale: ArrayLike,
    Xi: ArrayLike | None = None,
    *,
    n_quad: int = QUAD_NODES,
)

Bases: MaternPrior

MaternPrior computed in step-size-preconditioned coordinates.

The process is the same as MaternPrior, and A(h), Q(h), Q_sqr(h) and the stationary law are those of MaternPrior. The filters, however, compute each step in the coordinates x_bar = T(h)^-1 x, with the diagonal preconditioner of PrecondIWP. Unlike for the IWP, the preconditioned transition and noise still depend on h (they tend to the IWP constants as h -> 0).

Parameters:

Name Type Description Default
q int

Smoothness order (nu = q + 1/2).

required
d int

Dimension of the solution.

required
length_scale ArrayLike

Length scale l of the process, as for MaternPrior.

required
Xi ArrayLike | None

Component-correlation matrix, shape [d, d].

None
n_quad int

Gauss-Legendre nodes of the square-root decomposition.

QUAD_NODES

T

T(h: ArrayLike) -> Array

The diagonal preconditioner T(h) of PrecondIWP, [D, D].

transition

transition(h: ArrayLike) -> Transition

T^-1 A T and Q_sqr T^-T with the preconditioner T(h).

Scaling the columns of the upper-triangular square-root factor by the diagonal T^-1 keeps it upper triangular.

The transition and the base class

Transition

Bases: NamedTuple

One step of a prior, x' = A x + b + w with w ~ N(0, Q_sqr.T @ Q_sqr).

These are the matrices a filter step computes with. For a plain prior they act on the state itself (T_diag is None). A preconditioned prior returns them in the coordinates x_bar = x / T_diag (elementwise), in which they are better conditioned; the filter changes into those coordinates for the prediction and back, so its results are always in the original coordinates.

Attributes:

Name Type Description
A Array

Transition matrix, shape [D, D].

b Array

Drift, shape [D].

Q_sqr Array

Upper-triangular square-root process noise, shape [D, D].

T_diag Array | None

Diagonal of the preconditioner T(h) (x = T x_bar), shape [D], or None for a plain prior.

BasePrior

Bases: Module

Base class of the Gauss-Markov priors.

A prior models a d-dimensional solution x(t) together with its first q derivatives, stacked derivative-major into the state Y = [x, x', ..., x^(q)] of length (q+1)*d. Over a step of size h it is the linear-Gaussian transition Y(t+h) = A(h) Y(t) + b(h) + noise with process noise covariance Q(h) = Q_sqr(h).T @ Q_sqr(h). Subclasses define A and Q_sqr; the filters consume transition(h).

Priors are equinox modules: their hyperparameters (Xi, a length scale, a rate) are pytree leaves, so a prior can be differentiated, vmapped or passed through equinox.filter_jit like any array; the orders and dimensions are static.

Attributes:

Name Type Description
q AbstractVar[int]

Number of modelled derivatives (the smoothness order).

d AbstractVar[int]

Dimension of the solution x.

xi AbstractVar[Array]

Component-correlation matrix of the driving noise, shape [d, d]. It sets the scale of the prior uncertainty (together with the calibrated sigma^2).

xi_diagonal bool | None

Whether xi was diagonal when the prior was built (None if it was built from a traced Xi). Static, so the per-component calibration can check it under jit, where xi itself is traced. Replacing xi with equinox.tree_at does not update it; build a new prior instead.

E0 property

E0: Array

Selector of the solution x, shape [d, D].

E0_state property

E0_state: Array

Selector of the ODE solution in the state.

The adaptive error estimate measures this part only (Bosch, Tronarp & Hennig 2022, Sec. 3). It is E0 for a plain prior.

E1 property

E1: Array

Selector of x', shape [d, D].

E2 property

E2: Array | None

Selector of x'', shape [d, D], or None if q < 2.

state_dim property

state_dim: int

Dimension D of the state.

xi_state property

xi_state: Array

Xi of the state block (per-component calibration needs it diagonal).

xi_state_diagonal property

xi_state_diagonal: bool | None

Whether xi_state was diagonal at construction (None: unknown).

A abstractmethod

A(h: ArrayLike) -> Array

Transition matrix over a step h, shape [D, D].

Q

Q(h: ArrayLike) -> Array

Process noise covariance over a step h, shape [D, D].

Prefer Q_sqr: at high order the dense Q(h) is severely ill-conditioned, while its square-root factor stays accurate.

Q_sqr abstractmethod

Q_sqr(h: ArrayLike) -> Array

Upper-triangular square root of the process noise: Q_sqr.T @ Q_sqr == Q(h).

apply_state_sigma_sqr

apply_state_sigma_sqr(
    Q_sqr: Array, sigma_sqr: ArrayLike
) -> Array

Scale the state block of a square-root process noise by sigma^2.

A scalar scales the whole state block; a length-d vector (the per-component calibration) scales each component's columns across all q + 1 derivatives. A joint prior's input block is left alone (Schmidt et al. 2021).

apply_state_sigma_to_cov_sqr

apply_state_sigma_to_cov_sqr(
    P_sqr: Array, sigma_sqr: ArrayLike
) -> Array

Scale the state block of a square-root covariance by sigma^2 (post hoc).

b

b(h: ArrayLike) -> Array

Drift over a step h, shape [D] (zero for these priors).

sample

sample(
    key: Array,
    ts: ArrayLike,
    *,
    m_0: ArrayLike | None = None,
    P_0_sqr: ArrayLike | None = None,
) -> Array

A sample path of the prior at the times ts.

Exact: each interval is the prior's transition over h_i = ts[i+1] - ts[i] (ts may be non-uniform). The key is split into one key for the initial state and one per interval.

Parameters:

Name Type Description Default
key Array

A jax.random key.

required
ts ArrayLike

Increasing times, shape [K].

required
m_0 ArrayLike | None

Mean of the initial state; required unless the prior has a stationary law (stationary_cov_sqr), which is then used with zero mean.

None
P_0_sqr ArrayLike | None

Square-root covariance of the initial state (with m_0).

None

Returns:

Type Description
Array

The path, shape [K, D].

Raises:

Type Description
ValueError

If no initial law is given and the prior has no stationary one, or only one of m_0 / P_0_sqr is given.

transition

transition(h: ArrayLike) -> Transition

The matrices a filter step of size h computes with.

Plain priors return A(h), b(h) and Q_sqr(h); preconditioned priors override this to return them in preconditioned coordinates (see Transition).

Initialization

taylor_mode_initialization

taylor_mode_initialization(
    vf: VectorField,
    inits: ArrayLike | tuple[ArrayLike, ...],
    q: int,
    t0: float = 0.0,
    order: int = 1,
) -> tuple[Array, Array]

Exact initial derivatives of an ODE solution, by Taylor-mode autodiff.

Expands the solution through x0 (and dx0 for order=2) with jax.experimental.jet and returns the state [x, x', ..., x^(q)] with a zero covariance: the initial state is known exactly. Time is expanded along with the state (t' = 1), so the derivatives of a time-dependent vector field are exact too.

Parameters:

Name Type Description Default
vf VectorField

Vector field, vf(x, *, t) -> dx/dt for order=1 or vf(x, dx, *, t) -> d^2x/dt^2 for order=2.

required
inits ArrayLike | tuple[ArrayLike, ...]

x0 for order=1; the tuple (x0, dx0) for order=2.

required
q int

Number of derivatives to compute (the prior's order).

required
t0 float

Time of the initial value (default 0.0).

0.0
order int

Order of the ODE (1 or 2, default 1).

1

Returns:

Type Description
Array

(m_0, P_0_sqr): the derivative-major state, shape [(q+1) d], and

Array

a zero square-root covariance, shape [(q+1) d, (q+1) d].

Raises:

Type Description
TypeError

If vf is not callable.

ValueError

If q is negative, order is not 1 or 2, or inits does not match order.

joint_taylor_initialization

joint_taylor_initialization(
    vf: VectorField,
    inits: ArrayLike | tuple[ArrayLike, ArrayLike],
    *,
    prior: JointPrior,
    t0: float = 0.0,
    order: int = 1,
    u0: ArrayLike | None = None,
    input_cov_sqr: ArrayLike | None = None,
    state_cov_sqr: ArrayLike | None = None,
) -> tuple[Array, Array]

A consistent initial law for an ODE driven by a hidden input.

The input block has mean [u0, 0, ..., 0] and covariance S_u = input_cov_sqr.T @ input_cov_sqr, by default the input prior's stationary law. The state block's mean is the Taylor-mode initialization of the ODE driven by the input's truncated Taylor polynomial, whose coefficients are the input block: the augmented system [x, (x'), u, u', ..., u^(q_u)] with u^(j)' = u^(j+1) and u^(q_u)' = 0 is expanded, and the state's derivatives [x, x', ..., x^(q_x)] are read off. Their Jacobian J with respect to the input block (forward-mode autodiff at the input mean) carries the input's spread into the state block::

P_0 = [[S_x + J S_u J.T, J S_u], [S_u J.T, S_u]].

J is exact for an input that enters the vector field additively and a linearization otherwise. As in taylor_mode_initialization, time is expanded along with the state.

Parameters:

Name Type Description Default
vf VectorField

Vector field with the hidden-input signature, vf(x, u, *, t) (order=1) or vf(x, dx, u, *, t) (order=2), as for ODEInformationWithHidden / SecondOrderODEInformationWithHidden.

required
inits ArrayLike | tuple[ArrayLike, ArrayLike]

x0, or (x0, dx0) for order=2.

required
prior JointPrior

The JointPrior of state and input.

required
t0 float

Initial time.

0.0
order int

Order of the ODE (1 or 2).

1
u0 ArrayLike | None

Mean of the input at t0 (default zero, the stationary mean).

None
input_cov_sqr ArrayLike | None

Square root of the input block's covariance, shape [D_u, D_u]; defaults to the input prior's stationary_cov_sqr().

None
state_cov_sqr ArrayLike | None

Square root of the state block's own covariance, shape [D_x, D_x] (default zero: the Taylor Dirac).

None

Returns:

Type Description
Array

(m_0, P_0_sqr) in the JointPrior state order (the state block,

Array

then the input block). P_0_sqr is the square factor

tuple[Array, Array]

[[R_x, 0], [R_u J.T, R_u]] of P_0, not a triangular one: every

tuple[Array, Array]

consumer uses only P_0_sqr.T @ P_0_sqr, and a QR through the zero

tuple[Array, Array]

rows of the Dirac state block would have no derivative.

Raises:

Type Description
TypeError

If prior is not a JointPrior.

ValueError

If order is not 1 or 2, inits does not match it, or no input_cov_sqr is given for an input prior without a stationary law.