Ensemble Kalman Processes¶
Iterative ensemble methods for derivative-free parameter estimation. All
methods share the same outer loop — the caller supplies forward-model
evaluations G(θ⁽ʲ⁾) each step, the process supplies the ensemble
update rule. The Layer-2 wrappers (filterax.EKI, filterax.EKS,
filterax.TEKI, filterax.UKI) handle the loop for you; the artificial-time step Δtₙ is
controlled by a scheduler, and the iteration states
(ProcessState, UKIState,
ProcessConfig) are documented with the
Protocols & Types.
Picking a process¶
| Method | Output | UQ | Forward evals / step | Use when |
|---|---|---|---|---|
filterax.EKI |
Collapsing point estimate | None | J |
Default calibration; underdetermined OK (J ≥ p + 1) |
filterax.EKS |
Posterior samples | Full ensemble | J |
Posterior uncertainty matters; longer runs; pass prior_mean / prior_cov for a Bayesian prior |
filterax.TEKI |
MAP | None (spread is a convergence diagnostic) | J |
Point estimate under a Gaussian prior, without gradients |
filterax.UKI |
Parametric (μ, Σ) |
Calibrated Σ |
2 Nₚ + 1 (fixed) |
Moderate Nₚ ≲ 100, deterministic, reproducible |
filterax.processes.ETKI |
MLE | None | J |
Same as EKI — semantic alias; output-scalable variant for N_d ≫ J (current impl delegates to EKI's gaussx-Woodbury solve) |
filterax.processes.GNKI |
MAP + ensemble spread | Via spread | J |
Well-conditioned, fast convergence, requires J > Nₚ |
filterax.processes.SparseInversion |
Sparse point estimate | None | J |
Variable selection, sparse parameter recovery |
What each model targets¶
For a Bayesian inverse problem with prior \(\mathcal{N}(m_0, \Sigma_0)\) and noise \(\Gamma\), the models converge to different things:
EKI: a least-squares fit to \(y\) within the span of the initial ensemble. The prior enters only through that ensemble.TEKI: the MAP of \(\tfrac{1}{2}\|y - G(\theta)\|^2_{\Gamma^{-1}} + \tfrac{1}{2}\|\theta - m_0\|^2_{\Sigma_0^{-1}}\).EKSwithprior_mean/prior_cov: samples of the posterior \(p(\theta \mid y)\). Without them, samples of the likelihood (a flat prior). Use a small fixed step (FixedScheduler(dt=0.02)or so) for sampling;EKSStableSchedulercan pick steps too large for the data (#109).UKI: a Gaussian approximation, with the initial \((\mu_0, \Sigma_0)\) acting as the prior. Exact for a linear \(G\).
Decision tree¶
- Need posterior samples? → EKS
- Need calibrated parametric covariance? → UKI (if
Nₚ ≲ 100) - Sparse parameters? → SparseInversion
- Ill-posed / need prior regularisation? → TEKI
- Well-conditioned, want fast convergence? → GNKI (if
J > Nₚ) - Otherwise → EKI (simple, robust default)
Layer-2 API (run-loop wrappers)¶
These are the canonical entry points. Each composes the forward model,
a Layer-1 process, and a scheduler into a single .run() call returning a
ProcessResult.
filterax — differentiable ensemble Kalman filters and processes for JAX.
EKI
¶
Bases: Module
Ensemble Kalman Inversion — full init → update run loop.
Composes a :class:forward_fn (the simulator) with a Layer-1
:class:~filterax._processes._processes.EKI and a scheduler. Returns the
final parameter ensemble plus per-iteration history.
Attributes:
| Name | Type | Description |
|---|---|---|
forward_fn |
ForwardFn
|
|
obs |
Float[Array, ' N_d']
|
Observation vector |
noise_cov |
AbstractLinearOperator
|
Observation noise covariance |
scheduler |
AbstractScheduler
|
Step-size strategy. Defaults to
:class: |
config |
ProcessConfig | None
|
Optional :class: |
Source code in src/filterax/_processes/_process_models.py
EKS
¶
Bases: Module
Ensemble Kalman Sampler — full run loop.
Like :class:EKI but produces approximate posterior samples (the
ensemble does not collapse). Uses
:class:~filterax._processes._processes.EKS_Process with
:class:EKSStableScheduler by default; runs the full
n_iterations (no algo-time termination — burn-in + sampling).
Attributes:
| Name | Type | Description |
|---|---|---|
forward_fn |
ForwardFn
|
|
obs |
Float[Array, ' N_d']
|
Observation vector |
noise_cov |
AbstractLinearOperator
|
Observation noise covariance |
scheduler |
AbstractScheduler
|
Step-size strategy. Use :class: |
seed |
int
|
PRNG seed for the Brownian draws. |
config |
ProcessConfig | None
|
Optional :class: |
prior_mean |
Float[Array, ' N_p'] | None
|
Prior mean |
prior_cov |
AbstractLinearOperator | None
|
Prior covariance |
Source code in src/filterax/_processes/_process_models.py
TEKI
¶
Bases: Module
Tikhonov Ensemble Kalman Inversion — full run loop to the MAP.
EKI on the augmented system \(\tilde G(\theta) = (G(\theta), \theta)\), \(\tilde y = (y, m_0)\), \(\tilde\Gamma = \mathrm{blockdiag}(\Gamma, \Sigma_0)\) (Chada, Stuart & Tong 2020). The prior enters as data, so the iteration targets the maximum a posteriori estimate
whereas :class:EKI converges toward a least-squares fit in the span
of the initial ensemble. The MAP is a fixed point of every step, so
the run does not stop at algo_time = 1; it runs n_iterations
steps while the deterministic ensemble contracts onto it. The final
ensemble spread is a convergence diagnostic, not a posterior
uncertainty; use :class:EKS with the same prior for samples.
Attributes:
| Name | Type | Description |
|---|---|---|
forward_fn |
ForwardFn
|
|
obs |
Float[Array, ' N_d']
|
Observation vector |
noise_cov |
AbstractLinearOperator
|
Observation noise covariance |
prior_mean |
Float[Array, ' N_p']
|
Prior mean |
prior_cov |
AbstractLinearOperator
|
Prior covariance |
scheduler |
AbstractScheduler
|
Step-size strategy (default |
config |
ProcessConfig | None
|
Optional :class: |
Examples:
>>> import jax, jax.numpy as jnp, lineax as lx
>>> import filterax as flx
>>> F = jnp.array([[1.0, 0.5], [-0.3, 1.2], [0.7, 0.1]])
>>> y = jnp.array([0.9, -1.4, 0.6])
>>> teki = flx.TEKI(
... forward_fn=lambda th: F @ th,
... obs=y,
... noise_cov=lx.DiagonalLinearOperator(0.1 * jnp.ones(3)),
... prior_mean=jnp.zeros(2),
... prior_cov=lx.DiagonalLinearOperator(jnp.ones(2)),
... )
>>> init = jax.random.normal(jax.random.key(0), (50, 2))
>>> teki.run(init).mean.shape
(2,)
Source code in src/filterax/_processes/_process_models.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
UKI
¶
Bases: Module
Unscented Kalman Inversion — full parametric run loop.
Maintains μₙ and Σₙ rather than a random ensemble; uses
2 Nₚ + 1 deterministic sigma points per step.
Attributes:
| Name | Type | Description |
|---|---|---|
forward_fn |
ForwardFn
|
|
obs |
Float[Array, ' N_d']
|
Observation vector |
noise_cov |
AbstractLinearOperator
|
Observation noise covariance |
scheduler |
AbstractScheduler
|
Step-size strategy. Ignored when |
alpha, |
(beta, kappa)
|
Unscented tuning parameters; see
:func: |
config |
ProcessConfig | None
|
Optional :class: |
Source code in src/filterax/_processes/_process_models.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
ProcessResult
¶
Bases: Module
Output of a full EKP run.
Attributes:
| Name | Type | Description |
|---|---|---|
particles |
Float[Array, 'J N_p'] | None
|
Final ensemble ( |
mean |
Float[Array, ' N_p']
|
Final posterior-mean estimate. |
covariance |
AbstractLinearOperator
|
Final posterior covariance (UKI's parametric state; the ensemble sample covariance for EKI / EKS). |
history_particles |
Float[Array, 'Tp1 J N_p'] | None
|
Particles at every iteration, shape
|
history_algo_time |
Float[Array, ' T']
|
|
n_iterations |
int
|
Actual number of iterations run. |
converged |
bool
|
|
Source code in src/filterax/_processes/_process_models.py
Layer-1 components (advanced)¶
Drop down to these when you need per-step control of the loop (custom
convergence checks, JAX scan integration, etc.). All implement
AbstractProcess.
Layer-1 ensemble Kalman process components.
Re-exports the L1 process classes from
:mod:filterax._processes._processes so the canonical
filterax.processes.EKI() access path matches the design docs.
The Layer-2 filterax.EKI / filterax.EKS / filterax.UKI
wrappers live at the top level and own the full
init → forward eval → update loop.
EKI
¶
Bases: AbstractProcess
Ensemble Kalman Inversion (Iglesias, Law & Stuart 2013).
Iterative ensemble method that drives θ⁽ʲ⁾ toward a MAP /
regularised-least-squares solution. The update for each member:
The ensemble collapses to a point as algo_time → 1: spread → 0,
no posterior uncertainty (see :class:EKS_Process if you need
samples). Works in the underdetermined regime J < Nₚ.
Attributes:
| Name | Type | Description |
|---|---|---|
scheduler |
AbstractScheduler
|
Step-size strategy. Use
:class: |
Examples:
>>> import jax
>>> import jax.numpy as jnp
>>> import lineax as lx
>>> from filterax import FixedScheduler
>>> from filterax.processes import EKI
>>> G = jnp.array([[1.0, 0.5], [-0.3, 1.2]])
>>> obs = jnp.array([0.5, 0.9])
>>> noise = lx.DiagonalLinearOperator(0.1 * jnp.ones(2))
>>> eki = EKI(scheduler=FixedScheduler(dt=1.0))
>>> particles = jax.random.normal(jax.random.key(0), (4, 2))
>>> state = eki.init(particles, obs, noise)
>>> evals = jax.vmap(lambda theta: G @ theta)(state.particles)
>>> state = eki.update(state, evals)
>>> state.particles.shape, int(state.step)
((4, 2), 1)
Source code in src/filterax/_processes/_processes.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
EKS_Process
¶
Bases: AbstractProcess
Ensemble Kalman Sampler / ALDI (Garbuno-Inigo et al. 2020).
Interacting-Langevin ensemble that does not collapse — at
stationarity the particles are approximate samples from the
posterior p(θ | y). The per-step update is the EKI drift plus a
finite-sample mean correction and an ensemble-preconditioned
Brownian noise:
The prior term is present only when prior_mean and prior_cov
are given; without them the stationary law is the likelihood alone
(a flat prior), which is the behaviour before the prior was added.
The prior term is taken implicitly in θ, as in Garbuno-Inigo et al.
(2020, §4), so a prior much tighter than the ensemble contracts the
particles toward m₀ for any Δt instead of amplifying them.
The discrete-time recipe used here matches Garbuno-Inigo §4: an
EKI-style mean update (with Δt⁻¹ Γ tempering), the
(Nₚ + 1)/J drift term, and a noise term scaled by the
ensemble-space sqrt of Cᶿᶿ (which avoids the dense Nₚ × Nₚ
Cholesky — see comments below).
Use :class:~filterax.EKSStableScheduler to keep Δt inside the
stability region.
Attributes:
| Name | Type | Description |
|---|---|---|
scheduler |
AbstractScheduler
|
Step-size controller. Prefer EKSStableScheduler. |
key |
PRNGKeyArray
|
Base PRNG key for the Brownian draws. Each step uses
|
prior_mean |
Float[Array, ' N_p'] | None
|
Prior mean |
prior_cov |
AbstractLinearOperator | None
|
Prior covariance |
Source code in src/filterax/_processes/_processes.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
UKI
¶
Bases: AbstractProcess
Unscented Kalman Inversion (Huang, Schneider & Stuart 2022).
Parametric inversion that maintains a Gaussian belief
θ ~ 𝒩(μₙ, Σₙ) instead of an explicit ensemble. Each step
generates 2 Nₚ + 1 sigma points, evaluates the forward model on
them, and applies a Kalman update on the unscented statistics:
Deterministic (no sampling noise), no ensemble collapse, and the
covariance Σₙ gives a calibrated posterior in the linear-Gaussian
case.
The L1 protocol uses :class:ProcessState for compatibility with
DataMisfitController — the field particles carries the sigma
points (last 2 Nₚ + 1 evaluations); the parametric state lives in
:class:UKIState and is returned by :meth:init_parametric /
:meth:update_parametric for callers that prefer the explicit form.
Attributes:
| Name | Type | Description |
|---|---|---|
scheduler |
AbstractScheduler
|
Step-size strategy. |
alpha |
float
|
Unscented spread parameter; usually small (e.g. |
beta |
float
|
Prior moment weighting; |
kappa |
float
|
Secondary scaling, usually |
Source code in src/filterax/_processes/_processes.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | |
init_parametric(mean: Float[Array, ' N_p'], covariance: lx.AbstractLinearOperator, obs: Float[Array, ' N_d'], noise_cov: lx.AbstractLinearOperator) -> UKIState
¶
Initialise the parametric (μ, Σ) state.
Source code in src/filterax/_processes/_processes.py
update_parametric(state: UKIState, forward_evals: Float[Array, 'twoNp1 N_d'], *, obs: Float[Array, ' N_d'], noise_cov: lx.AbstractLinearOperator, dt: Float[Array, '']) -> UKIState
¶
One UKI step on the parametric state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
UKIState
|
Current |
required |
forward_evals
|
Float[Array, 'twoNp1 N_d']
|
Forward-model evaluations at the
|
required |
obs
|
Float[Array, ' N_d']
|
Observation vector. |
required |
noise_cov
|
AbstractLinearOperator
|
Observation noise covariance |
required |
dt
|
Float[Array, '']
|
Step size for this iteration. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Updated |
UKIState
|
class: |
Source code in src/filterax/_processes/_processes.py
init(particles: Float[Array, 'J N_p'], obs: Float[Array, ' N_d'], noise_cov: lx.AbstractLinearOperator) -> ProcessState
¶
Initialise from an ensemble proxy for the parametric belief.
Computes the empirical mean and covariance of particles and
stores them in the leading sigma point block. Provided so UKI
slots into the same init / update loop as the
ensemble-typed processes; for the cleaner parametric API use
:meth:init_parametric / :meth:update_parametric.
Source code in src/filterax/_processes/_processes.py
ETKI
¶
Bases: AbstractProcess
Ensemble Transform Kalman Inversion.
The "transform" variant of EKI. Conceptually identical to
:class:EKI on the analysis ensemble (in batch form both write the
same linear-Gaussian posterior); the intended distinction is that
ETKI rewrites the per-step solve in the J × J ensemble subspace,
yielding O(J² N_d) cost instead of O(N_d³) when N_d ≫ J.
The current implementation defers to the same Bessel-corrected EKI
delta as :class:EKI — gaussx routes the inner solve through the
Woodbury identity, so the dense (N_d, N_d) block is not formed
even though the outer call signature is identical. A future
optimisation can specialise the transform path explicitly when
N_d is extreme; for now the two classes coexist so users can
select the conceptually-appropriate one without paying a different
cost.
Attributes:
| Name | Type | Description |
|---|---|---|
scheduler |
AbstractScheduler
|
Step-size strategy. |
Source code in src/filterax/_processes/_processes.py
GNKI
¶
Bases: AbstractProcess
Gauss-Newton Kalman Inversion.
Estimates the Jacobian explicitly from ensemble perturbations
(J̃ ≈ Cᶿᴳ (Cᶿᶿ)⁻¹) and applies a Gauss-Newton update with prior
pull-back:
Faster convergence
than :class:EKI for well-conditioned problems and requires
J > Nₚ so Cᶿᶿ is invertible. In the linear-Gaussian limit
GNKI recovers the exact posterior mean and covariance.
Attributes:
| Name | Type | Description |
|---|---|---|
scheduler |
AbstractScheduler
|
Step-size strategy. |
prior_mean |
Float[Array, ' N_p']
|
Prior mean |
prior_cov |
AbstractLinearOperator
|
Prior covariance |
jitter |
float
|
Tikhonov regularisation added to |
Source code in src/filterax/_processes/_processes.py
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
SparseInversion
¶
Bases: AbstractProcess
Sparse Ensemble Kalman Inversion (Schneider, Stuart & Wu 2022).
Standard EKI step followed by an L¹ proximal soft-threshold:
drives inactive parameters exactly to zero. Useful for variable selection / sparse physics discovery / sensor placement.
Attributes:
| Name | Type | Description |
|---|---|---|
scheduler |
AbstractScheduler
|
Step-size strategy. |
penalty_weight |
float
|
|
Source code in src/filterax/_processes/_processes.py
TEKI
¶
Bases: AbstractProcess
Tikhonov-regularised Ensemble Kalman Inversion (Chada et al. 2019).
Standard EKI on an augmented system that includes the parameters in observation space:
The augmented identity block in Cᶿᴳ̃ pulls particles toward the
prior mean m₀ and prevents the ensemble from drifting arbitrarily
far from the prior — useful for ill-posed problems where vanilla EKI
diverges. Converges to the MAP estimate (not MLE).
Attributes:
| Name | Type | Description |
|---|---|---|
scheduler |
AbstractScheduler
|
Step-size strategy. |
prior_mean |
Float[Array, ' N_p']
|
Prior mean |
prior_cov |
AbstractLinearOperator
|
Prior covariance |
Source code in src/filterax/_processes/_processes.py
Sigma-point utilities¶
The unscented quadrature used by UKI is also exposed for direct use.
Layer-1 ensemble Kalman process components.
Re-exports the L1 process classes from
:mod:filterax._processes._processes so the canonical
filterax.processes.EKI() access path matches the design docs.
The Layer-2 filterax.EKI / filterax.EKS / filterax.UKI
wrappers live at the top level and own the full
init → forward eval → update loop.
sigma_points(mean: Float[Array, ' N_p'], cov: lx.AbstractLinearOperator, *, alpha: float = 1.0, beta: float = 2.0, kappa: float = 0.0) -> tuple[Float[Array, 'twoNp1 N_p'], Float[Array, ' twoNp1'], Float[Array, ' twoNp1']]
¶
Generate 2 Nₚ + 1 deterministic sigma points (Wan & van der Merwe 2000).
For mean μ and covariance Σ:
with weights for the mean and covariance:
√Σ comes from :func:gaussx.root_decomposition so structured
Σ (diagonal, low-rank, …) skips the dense Cholesky.
Returns:
| Type | Description |
|---|---|
Float[Array, 'twoNp1 N_p']
|
|
Float[Array, ' twoNp1']
|
|