Skip to content

Information

The information module defines the ODE constraints and the observation models of a probabilistic ODE solver. Its classes form four groups:

  • ODE classes define the constraint that the dynamical system imposes.
  • Constraint and data classes add conservation laws (Conservation) and noisy observations (Measurement, passed to a solver as measurements=).
  • Black-box models accept an arbitrary user-defined measurement function.
  • Transformed models apply a nonlinear state transformation and compose its Jacobian by the chain rule.

Class Hierarchy

ODE Information Classes

The module provides four ODE information classes, organized by ODE order and whether hidden states are present:

Class ODE Order Hidden States Vector Field Signature
ODEInformation 1st No vf(x, *, t) -> dx/dt
ODEInformationWithHidden 1st Yes vf(x, u, *, t) -> dx/dt
SecondOrderODEInformation 2nd No vf(x, v, *, t) -> d^2x/dt^2
SecondOrderODEInformationWithHidden 2nd Yes vf(x, v, u, *, t) -> d^2x/dt^2

Flexible Measurement Classes

Class Description
BlackBoxMeasurement User-defined g(state, t) with autodiff Jacobian
TransformedMeasurement Wraps any model with nonlinear state transformation

The separation into classes has three consequences:

  • No runtime conditionals. Each class has a fixed code path, so a compiled solve contains no branch over the type of the model.
  • Explicit signatures. The class determines the signature of the vector field.
  • Single responsibility. Each class handles exactly one case.

Composable Constraints

Further constraints are added with frozen dataclasses:

  • Conservation: Time-invariant linear constraints A @ x = p, passed via the ODE class's constraints= argument.
  • Measurement: Time-varying observations A @ x = z[t] at specified times. They are not constraints of the measurement model. Pass them to a solver as measurements=[Measurement(...)], and to marginal_loglik, fit or information_criteria as the data. These functions convert them into an ObsModel with prepare_observations([Measurement(...)], prior.E0_state, ts). Call prepare_observations where code needs the ObsModel itself (fenrir_loglik and conditional_loglik called directly, or one conversion reused in several solves), and pass the result as obs_model=. A acts on the solution x = prior.E0_state @ state (for a JointPrior, the solution without the input), or on the full state with full_state=True. A time between two grid nodes becomes a data-only node, where the filter conditions on the data without an update on the ODE information (see sharp bits). Measurements may have different times, and each step conditions on the rows that have data. Built inside jax.jit from concrete times, a Measurement may carry traced data.

Usage Examples

First-Order ODE

from ode_filters.priors import IWP
from ode_filters.information import ODEInformation

prior = IWP(q=2, d=1)

def vf(x, *, t):
    return -x  # exponential decay

model = ODEInformation(vf, prior.E0, prior.E1)

Second-Order ODE (e.g., Harmonic Oscillator)

from ode_filters.priors import IWP
from ode_filters.information import SecondOrderODEInformation

prior = IWP(q=3, d=1)
omega = 2.0

def vf(x, v, *, t):
    return -(omega**2) * x  # harmonic oscillator

model = SecondOrderODEInformation(vf, prior.E0, prior.E1, prior.E2)

Joint State-Parameter Estimation

To estimate unknown parameters together with the state, use JointPrior with the hidden-state classes:

import jax
import jax.numpy as np

from ode_filters import gaussian_filter
from ode_filters.information import Measurement, SecondOrderODEInformationWithHidden
from ode_filters.priors import IWP, JointPrior

jax.config.update("jax_enable_x64", True)

# Prior for the state x (q >= 2, so E2 exists) and the unknown damping u, a
# slowly drifting constant (a random walk with a small diffusion)
prior_joint = JointPrior(IWP(q=3, d=1), IWP(q=0, d=1, Xi=1e-4 * np.eye(1)))


def vf(x, v, u, *, t):  # damped oscillator x'' = -x - u x'
    return -x - u * v


model = SecondOrderODEInformationWithHidden(
    vf,
    E0=prior_joint.E0_x,  # extracts x
    E1=prior_joint.E1,  # extracts dx/dt
    E2=prior_joint.E2,  # extracts d^2x/dt^2
    E0_hidden=prior_joint.E0_hidden,  # extracts u
)

# Synthetic position data from the true damping u = 0.3
ts = np.linspace(0.0, 10.0, 201)
gamma = 0.15
omega_d = np.sqrt(1.0 - gamma**2)
obs_times = ts[10::10]
x_true = np.exp(-gamma * obs_times) * (
    np.cos(omega_d * obs_times) + gamma / omega_d * np.sin(omega_d * obs_times)
)

# Data go to the solver as measurements=, not into the measure. Measurement.A
# acts on prior_joint.E0_state @ state = E0_x @ state (the position x), so it is
# [n_obs, d_x]; observation times lie on the grid.
meas = Measurement(A=np.eye(1), z=x_true[:, None], z_t=obs_times, noise=1e-4)

# State layout [x, x', x'', x''', u]: start at rest at x = 1, u unknown
m_0 = np.array([1.0, 0.0, -1.0, 0.0, 0.0])
P_0_sqr = np.diag(np.array([0.0, 0.0, 0.0, 1.0, 1.0]))

result = gaussian_filter(m_0, P_0_sqr, prior_joint, model, ts, measurements=[meas])
u_hat = prior_joint.E0_hidden @ result.m[-1]  # estimated damping: ~0.297

Adding Conservation Laws

from ode_filters.information import ODEInformation, Conservation
import jax.numpy as np

# Energy conservation: x1 + x2 = 1
cons = Conservation(A=np.array([[1.0, 1.0]]), p=np.array([1.0]))

model = ODEInformation(vf, E0, E1, constraints=[cons])

Black-Box Measurement Models

When the residual does not have the structure of the ODE information classes, BlackBoxMeasurement defines an arbitrary differentiable measurement function. JAX computes its Jacobian by automatic differentiation.

Example:

from ode_filters.information import BlackBoxMeasurement
import jax.numpy as np

# Custom nonlinear observation: observe squared position and velocity
def custom_g(state, *, t):
    x, v = state[0], state[1]
    return np.array([x**2, v])

model = BlackBoxMeasurement(
    g_func=custom_g,
    state_dim=6,      # full state dimension (e.g., q=2, d=2 -> D=6)
    obs_dim=2,        # observation dimension
    noise=0.01        # measurement noise variance
)

# Use like any other measurement model
H, c = model.linearize(state, t=0.0)
R = model.noise_sqr(t=0.0)

As the measure of a solver, g plays the role of the ODE residual: the filter conditions on g(state) = 0, and all rows drive the diffusion calibration. If g stacks further rows after the ODE residual (e.g. conservation constraints), pass the number of leading rows that form the ODE defect as ode_dim=.

Transformed Measurement Models

TransformedMeasurement wraps a measurement model with a nonlinear state transformation sigma(state). The Jacobian of the mean follows from the chain rule, J_total = J_g(sigma(state)) @ J_sigma(state). Only the mean and the linearization are transformed. The measurement-noise covariance R is taken unchanged from the base model (see noise_sqr) and is not propagated through sigma, so R must be expressed in the coordinates of the base model after the transformation.

Use cases:

  • Nonlinear coordinate transformations (e.g., polar to Cartesian)
  • Applying constraints like softmax normalization
  • Feature extraction before measurement

Example with autodiff Jacobian:

from ode_filters.information import ODEInformation, TransformedMeasurement
from ode_filters.priors import IWP
import jax
import jax.numpy as np

# Base ODE model
def vf(x, *, t):
    return -x

prior = IWP(q=2, d=2)
base_model = ODEInformation(vf, prior.E0, prior.E1)

# Apply softmax to ensure state components sum to 1
def softmax_transform(state):
    x = state[:2]  # extract position components
    x_normalized = jax.nn.softmax(x)
    return state.at[:2].set(x_normalized)

model = TransformedMeasurement(base_model, softmax_transform)

# Jacobian includes chain rule automatically
H, c = model.linearize(state, t=0.0)

Example with explicit Jacobian:

Pass sigma_jacobian= to replace the automatic Jacobian of sigma, e.g. by a closed form:

def sigma_jacobian(state):
    # Custom Jacobian implementation
    return jax.jacfwd(softmax_transform)(state)

model = TransformedMeasurement(base_model, softmax_transform, sigma_jacobian=sigma_jacobian)

ODE information

ODEInformation

ODEInformation(
    vf: Callable[..., Array],
    E0: ArrayLike,
    E1: ArrayLike,
    constraints: list[Conservation] | None = None,
    *,
    R: ArrayLike | None = None,
)

Bases: BaseODEInformation

First-order ODE x' = f(x, t).

Parameters:

Name Type Description Default
vf Callable[..., Array]

Vector field vf(x, *, t) -> x'.

required
E0 ArrayLike

Selector of x, shape [d, D].

required
E1 ArrayLike

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

required
constraints list[Conservation] | None

Conservation laws.

None
R ArrayLike | None

Noise of the ODE rows (default zero).

None

ODEInformationWithHidden

ODEInformationWithHidden(
    vf: Callable[..., Array],
    E0: ArrayLike,
    E1: ArrayLike,
    E0_hidden: ArrayLike,
    constraints: list[Conservation] | None = None,
    *,
    R: ArrayLike | None = None,
)

Bases: BaseODEInformation

First-order ODE driven by a hidden input: x' = f(x, u, t).

The input u (a latent force, an unknown parameter) is part of the state, with its own prior (see JointPrior).

Parameters:

Name Type Description Default
vf Callable[..., Array]

Vector field vf(x, u, *, t) -> x'.

required
E0 ArrayLike

Selector of x, shape [d_x, D].

required
E1 ArrayLike

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

required
E0_hidden ArrayLike

Selector of u, shape [d_u, D].

required
constraints list[Conservation] | None

Conservation laws (on x).

None
R ArrayLike | None

Noise of the ODE rows (default zero).

None

SecondOrderODEInformation

SecondOrderODEInformation(
    vf: Callable[..., Array],
    E0: ArrayLike,
    E1: ArrayLike,
    E2: ArrayLike,
    constraints: list[Conservation] | None = None,
    *,
    R: ArrayLike | None = None,
)

Bases: BaseODEInformation

Second-order ODE x'' = f(x, x', t).

Parameters:

Name Type Description Default
vf Callable[..., Array]

Vector field vf(x, v, *, t) -> x''.

required
E0 ArrayLike

Selector of x, shape [d, D].

required
E1 ArrayLike

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

required
E2 ArrayLike

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

required
constraints list[Conservation] | None

Conservation laws.

None
R ArrayLike | None

Noise of the ODE rows (default zero).

None

SecondOrderODEInformationWithHidden

SecondOrderODEInformationWithHidden(
    vf: Callable[..., Array],
    E0: ArrayLike,
    E1: ArrayLike,
    E2: ArrayLike,
    E0_hidden: ArrayLike,
    constraints: list[Conservation] | None = None,
    *,
    R: ArrayLike | None = None,
)

Bases: BaseODEInformation

Second-order ODE driven by a hidden input: x'' = f(x, x', u, t).

Parameters:

Name Type Description Default
vf Callable[..., Array]

Vector field vf(x, v, u, *, t) -> x''.

required
E0 ArrayLike

Selector of x, shape [d_x, D].

required
E1 ArrayLike

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

required
E2 ArrayLike

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

required
E0_hidden ArrayLike

Selector of u, shape [d_u, D].

required
constraints list[Conservation] | None

Conservation laws (on x).

None
R ArrayLike | None

Noise of the ODE rows (default zero).

None

Constraints and observations

Conservation

Conservation(
    A: ArrayLike, p: ArrayLike, full_state: bool = False
)

Bases: Module

A conservation law A @ x = p, always active.

Attributes:

Name Type Description
A Array

Constraint matrix, shape [k, d] (on x = E0 @ state) or [k, state_dim] with full_state=True.

p Array

Conserved values, shape [k].

full_state bool

Whether A acts on the full state instead of x.

dim property

dim: int

Number of conserved quantities.

residual

residual(x: Array) -> Array

A @ x - p.

Measurement

Measurement(
    A: ArrayLike,
    z: ArrayLike,
    z_t: ArrayLike,
    noise: ArrayLike = DEFAULT_MEASUREMENT_NOISE,
    full_state: bool = False,
)

Bases: Module

Noisy linear data z[n] = A @ x(z_t[n]) + v at the times z_t.

Passed to the solvers as measurements=, or through prepare_observations, which matches the times to the solver's grid with a small tolerance (absorbing the ~1e-8 differences between NumPy and JAX linspace). A time between two grid nodes becomes a data-only node.

The matching runs on the host, so concrete times are kept as a NumPy array. They stay concrete when the Measurement is built inside jax.jit (or eqx.filter_jit, grad, vmap) from NumPy arrays, Python numbers or arrays that the traced function closes over, while z, A and the noise may be traced. Times that are traced (an argument of the traced function, a value computed in it, or the times of a Measurement passed in as an argument) are kept as they are, and prepare_observations raises a TypeError for them.

Attributes:

Name Type Description
A Array

Measurement matrix, shape [k, d], on the solution x = E0 @ state with E0 = prior.E0_state (for a JointPrior, the solution without the input); or [k, state_dim] with full_state=True.

z Array

Data, shape [n, k].

z_t Array | ndarray

Times of the data, shape [n] ([n, 1] is flattened); a NumPy array unless traced.

R Array

Noise covariance, [k, k]; given as noise= a variance, per-row variances or a covariance.

full_state bool

Whether A acts on the full state instead of x.

dim property

dim: int

Number of measured quantities k.

prepare_observations

prepare_observations(
    observations: Sequence[Measurement],
    E0: ArrayLike,
    ts: ArrayLike,
) -> ObsModel | None

Build an ObsModel for the solver's grid ts from Measurement objects.

The usual way to pass data is the list of Measurement objects itself. The solvers take it as measurements=, and marginal_loglik, fit and information_criteria as their data; each converts it with this function. Call it where code needs the ObsModel itself: for fenrir_loglik and conditional_loglik called directly, with obs_model.without_data() for the pass without data, or to reuse one conversion in several solves on the same grid.

Every measurement time t must lie in (ts[0], ts[-1]]. A time that matches a node of ts within 1e-7 + 1e-5 |t| is conditioned on at that node, after the ODE information. Any other time becomes a data-only node: the filter predicts to it, conditions on the data and continues without an update on the ODE information, so the ODE information is that of the grid ts whatever the data times. Times within the tolerance of each other share one data-only node. With data-only nodes, the ObsModel records its timeline (t, grid_node) and the solvers return their results on it. When every time is a node of ts, t is None.

Measurements may have different times: at each step only the rows with data are conditioned on. Several data of one measurement at one node are all conditioned on, through copies of the measurement's rows.

The time matching runs on the host, so the times and ts must be concrete, while the data values (and A, the noise and E0) may be traced: the measurements and the ObsModel can be built inside a jitted, differentiated or vmapped function (see Measurement).

Parameters:

Name Type Description Default
observations Sequence[Measurement]

The measurements.

required
E0 ArrayLike

Selector of the solution x in the state, shape [d, state_dim]. The A of a measurement acts on E0 @ state unless it has full_state=True. Pass prior.E0_state, which for a JointPrior selects the solution without the input.

required
ts ArrayLike

The solver's time grid, shape [N + 1], strictly increasing; ts[0] is the time of the initial state.

required

Returns:

Type Description
ObsModel | None

An ObsModel, or None when observations is empty.

Raises:

Type Description
ValueError

For an invalid grid, or a measurement time at or before ts[0] or after ts[-1].

TypeError

If ts or the measurement times are traced.

ObsModel

Bases: NamedTuple

Data observations for the solvers' obs_model.

Linear observations y = H x + v with a constant H and noise; only the data vary per step. Built by prepare_observations. Step n ends at node n + 1 of the solve. Without data-only nodes these are the nodes of the solver's grid ts, and t and grid_node are None. With data-only nodes they are the nodes of the timeline t, the grid with a node at each data time between its nodes; a solver checks that the grid nodes of the timeline are its ts.

Several data of one measurement at one node occupy copies of the measurement's rows, as many as its largest number of data at one node. At a step the copies without data are masked.

Attributes:

Name Type Description
H Array

Observation matrix, shape [obs_dim, state_dim].

R_sqr Array

Square-root noise covariance, shape [obs_dim, obs_dim].

c_seq Array

Offsets per step, -y where a row has data and zero elsewhere, shape [E, obs_dim].

mask Array

Which rows have data at each step, shape [E, obs_dim]. Rows without data are ignored, so measurements can have different times.

t Array | ndarray | None

The timeline, shape [E + 1]: the grid with the data-only nodes, a NumPy array unless traced. None when every datum lies on a node of the grid; the steps are then those of the grid.

grid_node Array | ndarray | None

Whether step n ends at a node of the grid (True) or at a data-only node (False), shape [E]; None with t.

without_data

without_data() -> ObsModel

This ObsModel without its data: no rows, on the same nodes.

A solver given it runs the pass without data on the nodes of this ObsModel, its data-only nodes included, and reports no data evidence (log_likelihood_obs is None). This is the pass without data that fenrir_loglik(data_free, obs_model) and conditional_loglik(data, data_free) take. With data-only nodes, a pass with obs_model=None runs on the grid alone and does not match this ObsModel.

Returns:

Type Description
ObsModel

An ObsModel with no rows (obs_dim = 0) and the same t

ObsModel

and grid_node.

Custom measurement models

Any object with the MeasurementModel interface works as a solver's measure. Three further members are optional. One feature needs each of them, and each has its own protocol, which the feature checks with isinstance before the call:

Protocol Member Needed by
EK0Linearizable linearize_ek0 TaylorCorrection(order=0)
HasNoiseCovariance R TransformedMeasurement.R
NoiseSettable with_noise TransformedMeasurement.with_noise

A model without an optional member works with every feature that does not need it. A feature whose member is missing raises an error that names the member (TypeError for TaylorCorrection(order=0), AttributeError for the others). The ODE-information models implement all three protocols. BlackBoxMeasurement implements HasNoiseCovariance and NoiseSettable, and TransformedMeasurement forwards both to its base model.

MeasurementModel

Bases: Protocol

A residual g(state, t) that the filters observe as zero.

The ODE-information models, BlackBoxMeasurement and TransformedMeasurement implement it; so can a custom model. The first ode_dim rows of g are the ODE residual (they drive the diffusion calibration); further rows, e.g. conservation laws, only update the state.

A feature that calls one of the optional members (EK0Linearizable, HasNoiseCovariance, NoiseSettable) checks for it and raises an error that names the member if the model lacks it.

ode_dim property

ode_dim: int

Number of leading rows of g that are ODE residual.

g

g(state: Array, *, t: ArrayLike) -> Array

The residual at state, shape [k].

jacobian_g

jacobian_g(state: Array, *, t: ArrayLike) -> Array

The Jacobian of the residual, shape [k, D].

linearize

linearize(
    state: Array, *, t: ArrayLike
) -> tuple[Array, Array]

(H, c) with H x + c the first-order expansion of g at state.

noise_sqr

noise_sqr(*, t: ArrayLike) -> Array

Upper-triangular square root of the residual's noise covariance.

EK0Linearizable

Bases: Protocol

A model with a zeroth-order (EK0) linearization.

TaylorCorrection(order=0) linearizes with linearize_ek0. The ODE-information models implement it.

linearize_ek0

linearize_ek0(
    state: Array, *, t: ArrayLike
) -> tuple[Array, Array]

(H, c) without the vector-field Jacobian in the ODE rows of H.

H state + c equals the residual at state.

HasNoiseCovariance

Bases: Protocol

A model that stores its noise covariance as R.

TransformedMeasurement.R returns the R of its base model. The ODE-information models, BlackBoxMeasurement and TransformedMeasurement implement it.

R property

R: Array

Noise covariance of the rows that carry noise.

These are the ODE rows of an ODE-information model and all rows of a BlackBoxMeasurement.

NoiseSettable

Bases: Protocol

A model that returns a copy of itself with a new noise.

TransformedMeasurement.with_noise calls with_noise of its base model. The ODE-information models, BlackBoxMeasurement and TransformedMeasurement implement it.

with_noise

with_noise(noise: ArrayLike) -> MeasurementModel

A copy with the noise noise.

noise is a variance, per-row variances or a covariance of the rows that carry noise (see HasNoiseCovariance).

BaseODEInformation

Bases: Module

The residual E_lhs @ Y - f(S_1 @ Y, ..., S_k @ Y, t) plus conservation rows.

Use one of the four public subclasses; they set the selectors. All of them implement the MeasurementModel protocol and are equinox modules: their arrays are pytree leaves, the vector field is static.

Attributes:

Name Type Description
vf Callable[..., Array]

The vector field f.

E0 Array

Selector of the solution x (conservation laws act on E0 @ Y).

E_lhs Array

Selector of the ODE's left-hand side (E1, or E2 for a second-order ODE): the Jacobian of the residual's affine part, which an EK0 linearization uses for the ODE rows.

selectors tuple[Array, ...]

Selectors of the vector field's arguments, in order.

constraints tuple[Conservation, ...]

Conservation laws.

R Array

Noise covariance of the ODE rows, shape [d, d] (zero by default: the ODE holds exactly).

E_args property

E_args: Array

The vector field's argument selectors, stacked: [S_1; ...; S_k].

The residual is affine in the state except through E_args @ state. Statistical linearization integrates over this projected subspace only (see slr_linearize), which keeps the quadrature dimension equal to the ODE dimension rather than the state dimension.

ode_dim property

ode_dim: int

Number of ODE-residual rows at the top of g (they drive calibration).

Conservation rows live on other scales, so the diffusion is estimated from these rows alone (Bosch, Tronarp & Hennig 2022, Pick-and-Mix Information Operators, Sec. 3).

state_dim property

state_dim: int

Dimension of the prior's state.

g

g(state: Array, *, t: ArrayLike) -> Array

The residual at state: ODE rows, then conservation rows.

jacobian_g

jacobian_g(state: Array, *, t: ArrayLike) -> Array

The Jacobian of the residual at state.

linearize

linearize(
    state: Array, *, t: ArrayLike
) -> tuple[Array, Array]

First-order (EK1) linearization: H x + c matches g to first order.

Parameters:

Name Type Description Default
state Array

Linearization point.

required
t ArrayLike

Time.

required

Returns:

Type Description
tuple[Array, Array]

(H, c).

linearize_ek0

linearize_ek0(
    state: Array, *, t: ArrayLike
) -> tuple[Array, Array]

Zeroth-order (EK0) linearization: the vector field held constant.

The ODE rows of the Jacobian reduce to E_lhs; the conservation rows are affine and exact. Only the residual is evaluated, never the vector-field Jacobian.

Parameters:

Name Type Description Default
state Array

Linearization point.

required
t ArrayLike

Time.

required

Returns:

Type Description
tuple[Array, Array]

(H, c) with H x + c equal to the residual at state.

noise_sqr

noise_sqr(*, t: ArrayLike) -> Array

Upper-triangular square root of the noise of all rows.

The ODE rows carry R; conservation rows are exact.

with_noise

with_noise(R: ArrayLike) -> BaseODEInformation

A copy whose ODE rows carry the noise R.

Parameters:

Name Type Description Default
R ArrayLike

A variance (scalar), per-row variances (length ode_dim) or a covariance ([ode_dim, ode_dim]).

required

BlackBoxMeasurement

BlackBoxMeasurement(
    g_func: Callable[..., Array],
    state_dim: int,
    obs_dim: int,
    noise: ArrayLike = 0.0,
    *,
    ode_dim: int | None = None,
)

Bases: Module

A measurement model from an arbitrary residual g(state, *, t).

The Jacobian comes from automatic differentiation. As a solver's measure, g plays the role of the ODE residual: the filter conditions on g(state) = 0.

Parameters:

Name Type Description Default
g_func Callable[..., Array]

Residual g(state, *, t) -> [obs_dim], differentiable in JAX.

required
state_dim int

Dimension of the state.

required
obs_dim int

Dimension of the residual.

required
noise ArrayLike

Noise of the residual: a variance, per-row variances or a covariance (default zero).

0.0
ode_dim int | None

Number of leading rows of g that are ODE residual; they alone drive the diffusion calibration. Defaults to obs_dim; pass a smaller value when g stacks further rows (e.g. conservation laws) after the ODE residual.

None
Example

def custom_g(state, *, t): ... return np.array([state[1] - state[0] ** 2]) measure = BlackBoxMeasurement(custom_g, state_dim=3, obs_dim=1)

g

g(state: Array, *, t: ArrayLike) -> Array

The residual at state, shape [obs_dim].

jacobian_g

jacobian_g(state: Array, *, t: ArrayLike) -> Array

The Jacobian of the residual, shape [obs_dim, state_dim].

linearize

linearize(
    state: Array, *, t: ArrayLike
) -> tuple[Array, Array]

First-order linearization (H, c) from one VJP pass.

Parameters:

Name Type Description Default
state Array

Linearization point.

required
t ArrayLike

Time.

required

Returns:

Type Description
tuple[Array, Array]

(H, c) with H x + c the first-order expansion of g.

noise_sqr

noise_sqr(*, t: ArrayLike) -> Array

Upper-triangular square root of the noise covariance.

with_noise

with_noise(noise: ArrayLike) -> BlackBoxMeasurement

A copy with the noise noise (variance, per-row variances or matrix).

TransformedMeasurement

TransformedMeasurement(
    base: MeasurementModel,
    sigma: Callable[[Array], Array],
    sigma_jacobian: Callable[[Array], Array] | None = None,
)

Bases: Module

A measurement model evaluated at a transformed state: g(sigma(state)).

The Jacobian follows the chain rule, J_g(sigma(state)) @ J_sigma(state). The noise is the base model's, unchanged: it must already be expressed in the base model's (post-transform) coordinates.

Uses: a link function on a component (e.g. a positivity transform of a latent input), a nonlinear change of coordinates, feature extraction.

Parameters:

Name Type Description Default
base MeasurementModel

The measurement model evaluated at the transformed state.

required
sigma Callable[[Array], Array]

The transformation sigma(state) -> state.

required
sigma_jacobian Callable[[Array], Array] | None

Its Jacobian; computed by automatic differentiation when not given.

None
Example

def softmax_transform(state): ... return state.at[:3].set(jax.nn.softmax(state[:3])) transformed = TransformedMeasurement( ... ODEInformation(vf, E0, E1), softmax_transform ... )

E_args property

E_args: Array

Argument selector, the base model's.

Valid whenever sigma acts within the coordinates the base already reads, as a link function on one component does: the composed residual is then still affine in the state except through E_args @ state. It matters for cost: without it, slr_linearize integrates over the whole state (n_nodes ** state_dim nodes instead of n_nodes ** len(args)). If sigma mixes in coordinates the base does not read, subclass and override this with the union of the two.

Raises:

Type Description
AttributeError

If the base declares no argument selector (e.g. a BlackBoxMeasurement); slr_linearize then integrates over the full state, which is correct.

R property

R: Array

The base model's noise covariance.

Raises:

Type Description
AttributeError

If the base stores no noise covariance (see HasNoiseCovariance).

ode_dim property

ode_dim: int

Number of ODE-residual rows, the base model's.

A transformation changes where the residual is evaluated, not how many of its rows are ODE residual.

g

g(state: Array, *, t: ArrayLike) -> Array

g(sigma(state)).

jacobian_g

jacobian_g(state: Array, *, t: ArrayLike) -> Array

J_g(sigma(state)) @ J_sigma(state).

linearize

linearize(
    state: Array, *, t: ArrayLike
) -> tuple[Array, Array]

First-order linearization of the composed residual.

Parameters:

Name Type Description Default
state Array

Linearization point (untransformed).

required
t ArrayLike

Time.

required

Returns:

Type Description
tuple[Array, Array]

(H, c).

noise_sqr

noise_sqr(*, t: ArrayLike) -> Array

The base model's noise factor.

with_noise

with_noise(noise: ArrayLike) -> TransformedMeasurement

A copy whose base model carries the noise noise.

Raises:

Type Description
AttributeError

If the base has no with_noise (see NoiseSettable).