Filters¶
The solvers return a FilterResult in the original state coordinates. The
module provides the following functions:
gaussian_filtersolves on a given time grid (uniform or not) and linearizes the ODE information at each prediction with aCorrection.gaussian_filter_adaptivetakes adaptive steps between given save times.affine_filterfilters a frozen linearization (anAffineSurrogate).rts_smoothersmooths any result that carries backward conditionals.sample_posteriordraws a joint sample path from the smoothing posterior.interpolatereturns filtered or smoothed marginals between the grid nodes.iterated_smootherimplements the IEKS and the IPLS, which linearize along the smoothed trajectory, filter and smooth, and repeat.
Every step calibrates the diffusion with the calibration= policy ("dynamic"
by default; see Diffusion calibration) and conditions on
the data, if any, after the ODE information. The solvers take the data as
measurements=, a list of Measurement objects, or as an obs_model built
with prepare_observations (see Information). A
preconditioned prior changes how a step is computed, not its result. See
How to choose.
Data between the grid nodes¶
A data time between two grid nodes becomes a data-only node. On the fixed grid
(gaussian_filter, affine_filter, iterated_smoother), the filter predicts
to it, conditions on the data and continues without an update on the ODE
information. The ODE information is that of the grid ts. At a data-only node
the ODE evidence is zero, and the ODE innovation is reported with zero mean and
an identity factor. The diffusion of a grid interval is estimated
once, at the interval's start, from the prediction over the whole interval,
and every step inside the interval propagates with it and reports it in
sigma_sqr and diffusion. The update on the ODE information at the
interval's end linearizes at the prediction that follows the data inside the
interval. The result lives on the timeline, the grid with the data-only nodes,
so rts_smoother, sample_posterior and interpolate apply unchanged.
iterated_smoother linearizes at the smoothed marginals of the grid nodes.
gaussian_filter_adaptive lands on every data time between the save times and
chooses its steps between them, so a data time is a full node there. Its result
also lives on the timeline.
The FilterResult¶
Recover a covariance with P = P_sqr.T @ P_sqr (see notation).
On K nodes, per-step fields have K - 1 entries; entry n belongs to the step
from t[n] to t[n + 1].
| Field | Meaning |
|---|---|
t |
the nodes: the time grid (the save times on the adaptive path), with the data-only nodes of the data, if any |
m, P_sqr |
filtered mean and square-root covariance |
log_likelihood |
ODE-information evidence, after calibration (not comparable across calibration policies) |
log_likelihood_obs |
data evidence, each observation conditioned on the ODE information up to its time (None without data) |
sigma_sqr |
per-step diffusion estimate (None on the adaptive path) |
diffusion |
the diffusion each step propagated with: sigma_sqr under a calibrating policy, ones under "none" (None on the adaptive path); interpolate bridges with it |
m_pred, P_pred_sqr |
predictions before each update (None on the adaptive path) |
G_back, d_back, P_back_sqr |
backward conditionals p(x_n \| x_{n+1}), consumed by rts_smoother |
mz, Pz_sqr |
ODE-information innovations; zero mean and identity factor at a data-only node |
mz_obs, Pz_obs_sqr |
data innovations; rows without data are zero with unit variance |
success |
adaptive: every save time reached with a finite evidence |
n_accepted, n_rejected |
adaptive: steps per save interval |
steps |
adaptive with record_steps > 0: every accepted step (a StepRecord) |
result.filtered and result.backward return the marginals and the backward
conditionals as a stacked Gaussian and Conditional.
By default (smoother=False), gaussian_filter_adaptive only filters. Its
backward fields are then None, and rts_smoother raises. With
smoother=True it composes one backward conditional per save interval
(O(#save points) memory), with or without data.
Solvers¶
gaussian_filter
¶
gaussian_filter(
m_0: ArrayLike,
P_0_sqr: ArrayLike,
prior: BasePrior,
measure: MeasurementModel,
ts: ArrayLike,
*,
correction: Correction | None = None,
calibration: Calibration | CalibrationMode = "dynamic",
obs_model: ObsModel | None = None,
measurements: Sequence[Measurement] | None = None,
checkpoint: bool = False,
) -> FilterResult
Gaussian ODE filter over the time grid ts.
Each step predicts with the prior, calibrates the diffusion, updates on the
ODE information linearized by correction at the prediction, and then on
the data, if any (see ode_filters.filters.kernel). The grid may be
non-uniform; on a uniform one the prior's transition is computed once.
Data between the grid nodes add data-only nodes, where the filter
conditions on the data without an update on the ODE information. The
diffusion of a grid interval is estimated at its start from the prediction
over the whole interval, and its steps propagate with it. The result then
lives on the timeline, the grid with the data-only nodes (see
ode_filters.filters.fixed_grid).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
m_0
|
ArrayLike
|
Initial mean, shape |
required |
P_0_sqr
|
ArrayLike
|
Initial square-root covariance, shape |
required |
prior
|
BasePrior
|
Gauss-Markov prior (plain or preconditioned). |
required |
measure
|
MeasurementModel
|
ODE-information model (the ODE plus conservation laws). |
required |
ts
|
ArrayLike
|
Time grid, shape |
required |
correction
|
Correction | None
|
Linearization ( |
None
|
calibration
|
Calibration | CalibrationMode
|
Diffusion calibration policy, or one of |
'dynamic'
|
obs_model
|
ObsModel | None
|
Data for the grid |
None
|
measurements
|
Sequence[Measurement] | None
|
The data as |
None
|
checkpoint
|
bool
|
Wrap each step in |
False
|
Returns:
| Type | Description |
|---|---|
FilterResult
|
A |
FilterResult
|
they have data-only nodes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For an invalid grid, an |
gaussian_filter_adaptive
¶
gaussian_filter_adaptive(
m_0: ArrayLike,
P_0_sqr: ArrayLike,
prior: BasePrior,
measure: MeasurementModel,
save_at: ArrayLike,
*,
correction: Correction | None = None,
calibration: Calibration | CalibrationMode = "dynamic",
obs_model: ObsModel | None = None,
measurements: Sequence[Measurement] | None = None,
atol: ArrayLike = 0.0001,
rtol: ArrayLike = 0.01,
h_init: ArrayLike | Literal["auto"] | None = None,
max_step: ArrayLike | None = None,
controller: StepSizeController | None = None,
sigma_in_error: SigmaInError = "per_step",
max_steps: int = 4096,
smoother: bool = False,
record_steps: int = 0,
) -> FilterResult
Adaptive-step Gaussian ODE filter, returning the solution at save_at.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
m_0
|
ArrayLike
|
Initial mean, shape |
required |
P_0_sqr
|
ArrayLike
|
Initial square-root covariance, shape |
required |
prior
|
BasePrior
|
Gauss-Markov prior (plain or preconditioned). Its |
required |
measure
|
MeasurementModel
|
ODE-information model (the ODE plus conservation laws). |
required |
save_at
|
ArrayLike
|
Strictly increasing save times; |
required |
correction
|
Correction | None
|
Linearization; |
None
|
calibration
|
Calibration | CalibrationMode
|
Diffusion calibration policy, or one of |
'dynamic'
|
obs_model
|
ObsModel | None
|
Data for the save times, from
|
None
|
measurements
|
Sequence[Measurement] | None
|
The data as |
None
|
atol
|
ArrayLike
|
Absolute tolerance of the local-error estimate. |
0.0001
|
rtol
|
ArrayLike
|
Relative tolerance of the local-error estimate. |
0.01
|
h_init
|
ArrayLike | Literal['auto'] | None
|
First trial step. |
None
|
max_step
|
ArrayLike | None
|
Upper bound on every step, the first trial step included;
|
None
|
controller
|
StepSizeController | None
|
Step-size controller; defaults to
|
None
|
sigma_in_error
|
SigmaInError
|
The diffusion in the error estimate. |
'per_step'
|
max_steps
|
int
|
Cap on attempts per save interval (it bounds the
checkpointed while-loop). Raise it, or loosen the tolerances, if
|
4096
|
smoother
|
bool
|
Also compose a backward conditional per save interval, so
|
False
|
record_steps
|
int
|
Record up to this many accepted steps in
|
0
|
Returns:
| Type | Description |
|---|---|
FilterResult
|
A |
FilterResult
|
they have data-only nodes. |
FilterResult
|
|
FilterResult
|
|
FilterResult
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
For an invalid |
affine_filter
¶
affine_filter(
m_0: ArrayLike,
P_0_sqr: ArrayLike,
prior: BasePrior,
surrogate: AffineSurrogate,
ts: ArrayLike,
*,
obs_model: ObsModel | None = None,
measurements: Sequence[Measurement] | None = None,
checkpoint: bool = False,
) -> FilterResult
Square-root Kalman filter of a frozen linearization.
Runs the same steps as gaussian_filter, but the ODE information of step
i is the given affine model surrogate.model(i) instead of a
linearization at the prediction. The diffusion is fixed (the prior carries
its scale); sigma_sqr reports the quasi-MLE over all rows of the
surrogate. The result supports everything a gaussian_filter result does,
e.g. rts_smoother. With data-only nodes, the surrogate keeps one model
per step of the grid ts, which updates at the grid node that ends the
step, and the result lives on the timeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
m_0
|
ArrayLike
|
Initial mean, shape |
required |
P_0_sqr
|
ArrayLike
|
Initial square-root covariance, shape |
required |
prior
|
BasePrior
|
Gauss-Markov prior (plain or preconditioned). |
required |
surrogate
|
AffineSurrogate
|
One affine model per step of |
required |
ts
|
ArrayLike
|
Time grid, shape |
required |
obs_model
|
ObsModel | None
|
Data for the grid |
None
|
measurements
|
Sequence[Measurement] | None
|
The data as |
None
|
checkpoint
|
bool
|
Wrap each step in |
False
|
Returns:
| Type | Description |
|---|---|
FilterResult
|
A |
FilterResult
|
they have data-only nodes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the surrogate does not have one model per step, or its
shapes do not match each other or the state; for an |
rts_smoother
¶
rts_smoother(result: FilterResult) -> Gaussian
Rauch-Tung-Striebel smoothing of a filter result.
Runs the stored backward conditionals p(x_n | x_{n+1}) from the last
filtered marginal back to the first. Works on any result that carries them:
gaussian_filter, affine_filter, and gaussian_filter_adaptive with
smoother=True (one composite conditional per save interval).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
FilterResult
|
A |
required |
Returns:
| Type | Description |
|---|---|
Gaussian
|
The smoothed marginals as a stacked |
Gaussian
|
square-root covariances |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the result carries no backward conditionals. |
Posterior samples and dense output¶
sample_posterior
¶
sample_posterior(key: Array, result: FilterResult) -> Array
A sample path from the smoothing posterior of a filter result.
Draws the last state from its filtered marginal, then each earlier state
from the backward conditional p(x_n | x_{n+1}). The result is an exact
sample of the joint posterior over all nodes, whereas independent draws
from the marginals would not be. The key is split into one key per node.
Vmap over keys for many paths.
With exact ODE information (zero noise R) the posterior is singular and
the path for a given key depends on which square-root factor the QR returns:
a batched and a looped run can differ, and the path is not smooth in the
model's parameters. Each path is still an exact draw. A small ODE noise,
e.g. measure.with_noise(1e-10), makes the paths reproducible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Array
|
A |
required |
result
|
FilterResult
|
A |
required |
Returns:
| Type | Description |
|---|---|
Array
|
The path at |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the result carries no backward conditionals. |
interpolate
¶
interpolate(
result: FilterResult,
prior: BasePrior,
ts: ArrayLike,
*,
smoothed: bool = True,
) -> Gaussian
Marginals of a fixed-grid result at times between its nodes.
For t in [t_n, t_{n+1}] the prior bridges the two nodes of
result.t (grid nodes or data-only nodes): predict from
the filtered state at t_n to t, and, for the smoothed marginal,
condition on the smoothed state at t_{n+1} through the backward
conditional of the remaining step. Each sub-step uses the diffusion its step
propagated with (result.diffusion), so the result agrees with the
filter and the smoother at the grid nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
FilterResult
|
A |
required |
prior
|
BasePrior
|
The prior the result was computed with. |
required |
ts
|
ArrayLike
|
Query times in |
required |
smoothed
|
bool
|
Return smoothed marginals (default) or filtered ones (the
prediction from the last node before |
True
|
Returns:
| Type | Description |
|---|---|
Gaussian
|
The marginals at |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the result has no per-step diffusion (an adaptive result). |
Result types¶
FilterResult
¶
Bases: NamedTuple
Result of a Gaussian ODE filter, in the original state coordinates.
The solve has K nodes; per-step arrays have K - 1 entries, entry
n belonging to the step from t[n] to t[n + 1]. Covariances are
square-root factors: P = P_sqr.T @ P_sqr.
Attributes:
| Name | Type | Description |
|---|---|---|
t |
Array
|
The nodes, shape |
m |
Array
|
Filtered means, shape |
P_sqr |
Array
|
Filtered square-root covariances, shape |
log_likelihood |
Array
|
ODE-information evidence,
|
log_likelihood_obs |
Array | None
|
Data evidence, |
sigma_sqr |
Array | None
|
Diffusion estimate per step, shape |
diffusion |
Array | None
|
The diffusion each step propagated with: |
m_pred |
Array | None
|
Predicted means per step, |
P_pred_sqr |
Array | None
|
Predicted square-root covariances per step. |
G_back |
Array | None
|
Gains of the backward conditionals |
d_back |
Array | None
|
Offsets of the backward conditionals. |
P_back_sqr |
Array | None
|
Square-root covariances of the backward conditionals. |
mz |
Array | None
|
Means of the ODE-information innovations per step (the residual at the predicted mean). Zero at a step that ends at a data-only node, which has no ODE update. |
Pz_sqr |
Array | None
|
Square-root covariances of the ODE-information innovations; the identity at a step that ends at a data-only node. |
mz_obs |
Array | None
|
Means of the data innovations per step, |
Pz_obs_sqr |
Array | None
|
Square-root covariances of the data innovations. Rows without data have unit variance and no correlation, so they add nothing to the whitened residual. |
success |
Array | None
|
Adaptive path: whether every save time was reached with a
finite log-likelihood ( |
n_accepted |
Array | None
|
Adaptive path: accepted steps per save interval. |
n_rejected |
Array | None
|
Adaptive path: rejected steps per save interval. |
steps |
StepRecord | None
|
Adaptive path with |
backward
property
¶
backward: Conditional
The backward conditionals as a stacked Conditional.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the result carries none (the adaptive path without
|
StepRecord
¶
Bases: NamedTuple
The accepted steps of an adaptive solve, in order.
Rows past count (or past the record's length, if the solve took more
steps than it holds) are NaN.
Attributes:
| Name | Type | Description |
|---|---|---|
t |
Array
|
Time at the end of each accepted step, shape |
h |
Array
|
Size of each accepted step, shape |
m |
Array
|
Filtered mean after each accepted step, shape |
sigma_sqr |
Array
|
Diffusion estimate of each accepted step, shape |
count |
Array
|
Number of accepted steps of the whole solve. |
Iterated smoothing¶
iterated_smoother
¶
iterated_smoother(
m_0: ArrayLike,
P_0_sqr: ArrayLike,
prior: BasePrior,
measure: MeasurementModel,
ts: ArrayLike,
*,
linearization: Literal["taylor", "slr"] = "taylor",
n_iters: int = 3,
init: ArrayLike | None = None,
init_P_sqr: ArrayLike | None = None,
obs_model: ObsModel | None = None,
measurements: Sequence[Measurement] | None = None,
rule: QuadratureRule = "gauss_hermite",
n_nodes: int = 4,
diagnostics: Callable[[IterationState], Any]
| None = None,
checkpoint: bool = False,
) -> IteratedSmootherResult
Iterated smoother (IEKS / IPLS) over a time grid.
Without init, the first linearization point is the smoothed trajectory
of a one-shot filter with the matching correction (EK1 for Taylor, a
QuadratureCorrection for SLR). Each of the n_iters passes then
linearizes along the current point (taylor_surrogate /
slr_surrogate), runs affine_filter and rts_smoother, and takes
the smoothed marginals as the next point. n_iters=0 returns the
one-shot filter and smoother.
With data-only nodes (data between the grid nodes, see
prepare_observations), the surrogates stay on the grid: each pass
linearizes at the smoothed marginals of the grid nodes, while its filter
and smoother run over the timeline of the data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
m_0
|
ArrayLike
|
Initial mean, shape |
required |
P_0_sqr
|
ArrayLike
|
Initial square-root covariance, shape |
required |
prior
|
BasePrior
|
Gauss-Markov prior (plain or preconditioned) carrying the diffusion scale. |
required |
measure
|
MeasurementModel
|
ODE-information model. |
required |
ts
|
ArrayLike
|
Time grid, shape |
required |
linearization
|
Literal['taylor', 'slr']
|
|
'taylor'
|
n_iters
|
int
|
Number of passes ( |
3
|
init
|
ArrayLike | None
|
Warm start: the means at nodes |
None
|
init_P_sqr
|
ArrayLike | None
|
With |
None
|
obs_model
|
ObsModel | None
|
Data for the same grid, from |
None
|
measurements
|
Sequence[Measurement] | None
|
The data as |
None
|
rule
|
QuadratureRule
|
Quadrature rule for |
'gauss_hermite'
|
n_nodes
|
int
|
Gauss-Hermite nodes per dimension for |
4
|
diagnostics
|
Callable[[IterationState], Any] | None
|
Optional traceable |
None
|
checkpoint
|
bool
|
Wrap each filter step, of the one-shot filter and of every
pass, in |
False
|
Returns:
| Type | Description |
|---|---|
IteratedSmootherResult
|
An |
Raises:
| Type | Description |
|---|---|
ValueError
|
For an unknown |
IteratedSmootherResult
¶
Bases: NamedTuple
Result of iterated_smoother.
Attributes:
| Name | Type | Description |
|---|---|---|
t |
Array
|
The nodes of the solve: the grid, shape |
m |
Array
|
Smoothed means of the final pass at |
P_sqr |
Array
|
Smoothed square-root covariances of the final pass. |
filter |
FilterResult
|
|
surrogate |
AffineSurrogate | None
|
The linearization the final pass used ( |
n_iters |
int
|
Number of passes. |
step |
Array
|
RMS change of the smoothed means at grid nodes |
diagnostics |
Any
|
The |
IterationState
¶
Bases: NamedTuple
What one pass of iterated_smoother produced (passed to diagnostics).
Attributes:
| Name | Type | Description |
|---|---|---|
surrogate |
AffineSurrogate
|
The linearization of the pass. |
filter_result |
FilterResult
|
Its filter result. |
m_smooth |
Array
|
Its smoothed means at the nodes of the solve, shape
|
P_smooth_sqr |
Array
|
Its smoothed square-root covariances. |
previous_point |
Array
|
The means it linearized at (grid nodes |
The filter step¶
The step every solver is built from, for building new drivers.
filter_step
¶
filter_step(
x: Gaussian,
transition: Transition,
information: Information,
*,
t: ArrayLike,
calibration: Calibration,
scale_noise: Callable[[Array, Array], Array],
observation: AffineModel | None = None,
mask: Array | None = None,
) -> StepOutput
One step: calibrate, predict, update on the information, observe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Gaussian
|
The state at the previous node. |
required |
transition
|
Transition
|
The prior's transition over the step. |
required |
information
|
Information
|
The ODE information of the step. |
required |
t
|
ArrayLike
|
The time of the step's update (the next node). |
required |
calibration
|
Calibration
|
Diffusion calibration policy. |
required |
scale_noise
|
Callable[[Array, Array], Array]
|
Applies a diffusion to the prior's noise
( |
required |
observation
|
AffineModel | None
|
The step's data model, or |
None
|
mask
|
Array | None
|
Which rows of |
None
|
Returns:
| Type | Description |
|---|---|
StepOutput
|
The step's |
estimate_diffusion
¶
estimate_diffusion(
x: Gaussian,
transition: Transition,
information: Information,
*,
t: ArrayLike,
calibration: Calibration,
) -> tuple[Array, Array, AffineModel]
The diffusion of a step, from the ODE residual at its predicted mean.
The diffusion is estimated before the predicted covariance exists, from the
information linearized at the predicted mean A m + b; the ODE rows alone
drive it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Gaussian
|
The state at the start of the step. |
required |
transition
|
Transition
|
The prior's transition over the step. |
required |
information
|
Information
|
The ODE information at the end of the step. |
required |
t
|
ArrayLike
|
The time at the end of the step. |
required |
calibration
|
Calibration
|
Diffusion calibration policy. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
|
Array
|
propagate with, and the information linearized at the predicted mean. |
StepOutput
¶
Bases: NamedTuple
Everything one filter step produces (original coordinates).
Attributes:
| Name | Type | Description |
|---|---|---|
predicted |
Gaussian
|
The prediction |
backward |
Conditional
|
The backward conditional |
innovation |
Gaussian
|
Predictive distribution of the ODE-information residual. |
filtered |
Gaussian
|
The updated state at |
sigma_sqr |
Array
|
The diffusion estimate of the step. |
diffusion |
Array
|
The diffusion the step propagated with: |
log_likelihood |
Array
|
The ODE-information evidence of the step. |
innovation_obs |
Gaussian | None
|
Predictive distribution of the data residual ( |
log_likelihood_obs |
Array | None
|
The data evidence of the step ( |
predict
¶
predict(
x: Gaussian, transition: Transition
) -> tuple[Gaussian, Conditional]
Prediction and backward conditional of one transition.
For a preconditioned transition both are computed in its coordinates and returned in the original ones.
observe
¶
observe(
x: Gaussian, model: AffineModel, mask: Array
) -> tuple[Gaussian, Gaussian, Array]
Condition on the data rows of model that mask marks as present.
A row without data is replaced by an exact observation of zero with unit
noise and a zero row in H: it leaves the state unchanged, its innovation
is N(0, 1) and uncorrelated with the other rows, and its log-density
-log(2 pi) / 2 is removed from the evidence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Gaussian
|
The state before the data. |
required |
model
|
AffineModel
|
The observation model of the step ( |
required |
mask
|
Array
|
Boolean, one entry per row of |
required |
Returns:
| Type | Description |
|---|---|
tuple[Gaussian, Gaussian, Array]
|
|
Step-size control¶
See Adaptive step-size control.
StepSizeController
¶
Bases: Protocol
Duck-typed interface for step-size controllers.
The adaptive solvers call propose after every attempted step, from
inside jax tracing in the jittable solver, so it must be written with
jax.numpy (no float() / Python min / max on its inputs).
err_prev is the normalised error of the previously accepted step. The
absence of that memory (first step, or right after a reject) is signalled
by None or, inside traced code, by a non-positive value.
propose
¶
Return the proposed next step size.
PController
dataclass
¶
PController(
order: int,
safety: float = 0.9,
alpha: float | None = None,
min_factor: float = 0.2,
max_factor: float = 5.0,
)
Proportional (single-error) step-size controller.
The proposed step is
h_new = h * safety * err^(-alpha)
clipped to [min_factor, max_factor] * h. The previous error is
ignored, so this controller has no memory.
Default alpha = 1 / order matches the standard "I-controller" of
Hairer-Wanner-Norsett (1993) and the elementary controller in scipy's
solve_ivp. For an EK1 filter with an IWP(q) prior, order = q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order
|
int
|
Convergence order of the local error estimate. |
required |
safety
|
float
|
Safety factor on the proposed step. |
0.9
|
alpha
|
float | None
|
Gain on the current error; defaults to |
None
|
min_factor
|
float
|
Lower clip on |
0.2
|
max_factor
|
float
|
Upper clip on |
5.0
|
propose
¶
Return the next proposed step size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h
|
ArrayLike
|
Current step size. |
required |
err
|
ArrayLike
|
Normalised error of the current step (1.0 = at tolerance). |
required |
err_prev
|
ArrayLike | None
|
Ignored; accepted for protocol compatibility with
|
None
|
PIController
dataclass
¶
PIController(
order: int,
safety: float = 0.9,
alpha: float | None = None,
beta: float | None = None,
min_factor: float = 0.2,
max_factor: float = 5.0,
)
Gustafsson-style proportional-integral controller.
The proposed step is
h_new = h * safety * err^(-alpha) * (err_prev / err)^(beta)
clipped to [min_factor, max_factor] * h. When err_prev is unknown
(e.g. on the first step or right after a reject) the I-term is dropped
and the update reduces to the PController form
h_new = h * safety * err^(-alpha).
Defaults follow Gustafsson (1991): alpha = 0.7 / order, beta = 0.4 /
order, which are also the values used in Bosch et al. (2021). For an
EK1 filter with an IWP(q) prior, order = q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order
|
int
|
Convergence order of the local error estimate. |
required |
safety
|
float
|
Safety factor on the proposed step. |
0.9
|
alpha
|
float | None
|
Proportional gain; defaults to |
None
|
beta
|
float | None
|
Integral gain; defaults to |
None
|
min_factor
|
float
|
Lower clip on |
0.2
|
max_factor
|
float
|
Upper clip on |
5.0
|
propose
¶
Return the next proposed step size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h
|
ArrayLike
|
Current step size. |
required |
err
|
ArrayLike
|
Normalised error of the current step (1.0 = at tolerance). |
required |
err_prev
|
ArrayLike | None
|
Normalised error of the previously accepted step, or
|
required |