Gaussian algebra¶
The QR-based numerical core every filter step is built on. Covariances are
propagated as upper-triangular factors P_sqr (with P = P_sqr.T @ P_sqr), never
as dense matrices, which keeps them symmetric and positive-semi-definite (no
indefiniteness from round-off; see notation).
A filter step is marginalize (predict) and invert (the backward conditional),
then update (condition on the information, observed as zero), with
log_likelihood of the innovation as its evidence. The adaptive smoother uses
compose.
Types¶
Gaussian
¶
Bases: NamedTuple
A Gaussian N(m, P) with P = P_sqr.T @ P_sqr.
Stacked along a leading axis it is a sequence of marginals, e.g. the
smoothed solution: m of shape [K, n] and P_sqr of shape
[K, n, n].
Attributes:
| Name | Type | Description |
|---|---|---|
m |
Array
|
Mean, shape |
P_sqr |
Array
|
Square-root covariance, shape |
Conditional
¶
Bases: NamedTuple
An affine Gaussian conditional x | y ~ N(G y + d, P).
The filters store one per step, p(x_n | x_{n+1}): the backward
conditional that smoothing and posterior sampling run on.
Attributes:
| Name | Type | Description |
|---|---|---|
G |
Array
|
Gain, shape |
d |
Array
|
Offset, shape |
P_sqr |
Array
|
Square-root covariance, shape |
AffineModel
¶
Bases: NamedTuple
An affine Gaussian observation model z | x ~ N(H x + c, R).
The filters condition on z = 0: an ODE-information or data model
linearized at some state, with c holding the (negated) data.
Attributes:
| Name | Type | Description |
|---|---|---|
H |
Array
|
Observation matrix, shape |
c |
Array
|
Offset, shape |
R_sqr |
Array
|
Square-root noise covariance, shape |
Operations¶
marginalize
¶
Marginal of z = A x + b + w with x ~ N(m, P) and w ~ N(0, Q).
z ~ N(A m + b, A P A.T + Q), with the covariance factor from one QR of
[P_sqr A.T; Q_sqr] (see the module docstring).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Array
|
Linear map, shape |
required |
b
|
Array
|
Offset, shape |
required |
Q_sqr
|
Array
|
Square-root noise covariance, shape |
required |
x
|
Gaussian
|
The Gaussian over |
required |
Returns:
| Type | Description |
|---|---|
Gaussian
|
The Gaussian over |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the shapes do not match. |
invert
¶
invert(
A: Array, Q_sqr: Array, x: Gaussian, z: Gaussian
) -> Conditional
Bayes' rule for z = A x + b + w: the conditional p(x | z).
Given the prior x and the marginal z (from marginalize with the
same A, b, Q_sqr), returns x | z ~ N(G z + d, Lambda) with the
gain G = P A.T Cov(z)^-1, d = m - G E[z] and the Joseph form
Lambda = (I - G A) P (I - G A).T + G Q G.T. Observing z = 0 gives the
posterior N(d, Lambda); in the filters' prediction it is the backward
conditional p(x_n | x_{n+1}).
A component of z with exactly zero variance gets a zero gain column (the
pseudo-inverse of Cov(z)): it carries no information about x. This is
the backward conditional after an exactly zero calibrated diffusion from an
exact initial value, e.g. a solve started at an equilibrium. A Cov(z)
that is singular in a direction mixing components still gives NaN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Array
|
Linear map, shape |
required |
Q_sqr
|
Array
|
Square-root noise covariance of |
required |
x
|
Gaussian
|
The prior over |
required |
z
|
Gaussian
|
The marginal over |
required |
Returns:
| Type | Description |
|---|---|
Conditional
|
The conditional |
update
¶
update(
model: AffineModel, x: Gaussian
) -> tuple[Gaussian, Gaussian]
Condition x on observing z = 0 under z = H x + c + v.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
AffineModel
|
The observation model; the data enter through |
required |
x
|
Gaussian
|
The prior. |
required |
Returns:
| Type | Description |
|---|---|
Gaussian
|
|
Gaussian
|
predictive distribution of |
tuple[Gaussian, Gaussian]
|
prior mean), whose density at zero is the step's evidence. |
compose
¶
compose(
outer: Conditional, inner: Conditional
) -> Conditional
Compose p(x | y) (outer) and p(y | z) (inner) into p(x | z).
G = G1 G2, d = G1 d2 + d1, P = G1 P2 G1.T + P1: the marginal of
the inner conditional's noise pushed through the outer one. Used by the
adaptive fixed-point smoother to merge the per-step backward conditionals
of a save interval into one (Kraemer 2025, "Adaptive Probabilistic ODE
Solvers Without Adaptive Memory Requirements", Eq. 18/19).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outer
|
Conditional
|
|
required |
inner
|
Conditional
|
|
required |
Returns:
| Type | Description |
|---|---|
Conditional
|
|