Inference
Inference routines for ODE filtering.
ode_filters.inference.sqr_inversion(A: Array, mu: Array, Sigma_sqr: Array, mu_z: Array, Sigma_z_sqr: Array, Q_sqr: Array | None = None) -> tuple[Array, Array, Array]
Numerically stable Bayesian inference using square-root representations.
Performs Bayesian update of a Gaussian given a linear observation model, using Cholesky factors and QR decomposition to maintain numerical stability.
Given p(x) ~ N(mu, Sigma) and p(z|x) ~ N(Ax + b, Q), computes the posterior p(x|z) in square-root form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Array
|
Observation matrix (shape [n_obs, n_state]). |
required |
mu
|
Array
|
Prior mean (shape [n_state]). |
required |
Sigma_sqr
|
Array
|
Square root of prior covariance (shape [n_state, n_state]). |
required |
mu_z
|
Array
|
Marginal observation mean (shape [n_obs]). |
required |
Sigma_z_sqr
|
Array
|
Square root of marginal observation covariance (shape [n_obs, n_obs]). |
required |
Q_sqr
|
Array | None
|
Square root of measurement noise covariance (optional). |
None
|
Returns:
| Type | Description |
|---|---|
Array
|
Tuple of (G, d, Lambda_sqr) where: |
Array
|
|
Array
|
|
tuple[Array, Array, Array]
|
|
ode_filters.inference.sqr_marginalization(A: Array, b: Array, Q_sqr: Array, mu: Array, Sigma_sqr: Array) -> tuple[Array, Array]
Marginalize out the linear transformation in a Gaussian model using square-root form.
Computes the marginal distribution of z = Ax + b given p(x) ~ N(mu, Sigma) and p(z|x) ~ N(Ax + b, Q). The result is p(z) = N(mu_z, Sigma_z) where: - mu_z = A @ mu + b - Sigma_z = A @ Sigma @ A.T + Q
The square-root form is preserved to maintain numerical stability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Array
|
Linear transformation matrix (shape [n_obs, n_state]). |
required |
b
|
Array
|
Observation offset (shape [n_obs]). |
required |
Q_sqr
|
Array
|
Square root of observation noise covariance. Shape [n_obs, n_obs] or [n_obs]. If 1D array, will be converted to 2D. |
required |
mu
|
Array
|
Prior mean (shape [n_state]). |
required |
Sigma_sqr
|
Array
|
Square root of prior covariance (shape [n_state, n_state]). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Tuple of (mu_z, Sigma_z_sqr) where: |
Array
|
|
tuple[Array, Array]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If input shapes are incompatible or invalid. |