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
¶
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 |
required |
Xi
|
ArrayLike | None
|
Component-correlation matrix of the driving noise, shape |
None
|
Q_sqr
¶
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 ( |
required |
d
|
int
|
Dimension of the solution. |
required |
length_scale
|
ArrayLike
|
Length scale |
required |
Xi
|
ArrayLike | None
|
Component-correlation matrix, shape |
None
|
n_quad
|
int
|
Gauss-Legendre nodes of the square-root decomposition (must
exceed |
QUAD_NODES
|
stationary_cov_sqr
¶
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 |
required |
d
|
int
|
State dimension. |
required |
rate
|
ArrayLike
|
OU rate of the highest derivative: a scalar (uniform), a length- |
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 |
QUAD_NODES
|
JointPrior
¶
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 |
xi_state_diagonal
property
¶
Whether the state prior's Xi was diagonal at construction.
Q_sqr
¶
Block-diagonal of the blocks' square roots (Q is block-diagonal).
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
¶
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 |
required |
Xi
|
ArrayLike | None
|
Component-correlation matrix of the driving noise, shape |
None
|
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 ( |
required |
d
|
int
|
Dimension of the solution. |
required |
length_scale
|
ArrayLike
|
Length scale |
required |
Xi
|
ArrayLike | None
|
Component-correlation matrix, shape |
None
|
n_quad
|
int
|
Gauss-Legendre nodes of the square-root decomposition. |
QUAD_NODES
|
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 |
b |
Array
|
Drift, shape |
Q_sqr |
Array
|
Upper-triangular square-root process noise, shape |
T_diag |
Array | None
|
Diagonal of the preconditioner |
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 |
xi |
AbstractVar[Array]
|
Component-correlation matrix of the driving noise, shape |
xi_diagonal |
bool | None
|
Whether |
E0_state
property
¶
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.
xi_state
property
¶
Xi of the state block (per-component calibration needs it diagonal).
xi_state_diagonal
property
¶
Whether xi_state was diagonal at construction (None: unknown).
Q
¶
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
¶
Upper-triangular square root of the process noise: Q_sqr.T @ Q_sqr == Q(h).
apply_state_sigma_sqr
¶
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
¶
Scale the state block of a square-root covariance by sigma^2 (post hoc).
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 |
required |
ts
|
ArrayLike
|
Increasing times, shape |
required |
m_0
|
ArrayLike | None
|
Mean of the initial state; required unless the prior has a
stationary law ( |
None
|
P_0_sqr
|
ArrayLike | None
|
Square-root covariance of the initial state (with |
None
|
Returns:
| Type | Description |
|---|---|
Array
|
The path, shape |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no initial law is given and the prior has no
stationary one, or only one of |
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, |
required |
inits
|
ArrayLike | tuple[ArrayLike, ...]
|
|
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
|
|
Array
|
a zero square-root covariance, shape |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
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, |
required |
inits
|
ArrayLike | tuple[ArrayLike, ArrayLike]
|
|
required |
prior
|
JointPrior
|
The |
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 |
None
|
input_cov_sqr
|
ArrayLike | None
|
Square root of the input block's covariance, shape
|
None
|
state_cov_sqr
|
ArrayLike | None
|
Square root of the state block's own covariance, shape
|
None
|
Returns:
| Type | Description |
|---|---|
Array
|
|
Array
|
then the input block). |
tuple[Array, Array]
|
|
tuple[Array, Array]
|
consumer uses only |
tuple[Array, Array]
|
rows of the Dirac state block would have no derivative. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |