API Reference

Type

RecursiveGPs.RGP — Type
struct RGP{bT, mT, BT, RT, cT}

Recursive Gaussian process [1]: a GP prior represented by its values at the basis points b0. The values at b0 are the state of a Kalman filter, with prior mean $\mu_0 = m(b_0)$ and covariance $\Sigma_0 = K_{b_0 b_0} + \varepsilon I$. See Mathematical Background for the derivation.

Fields

  • gp: The underlying AbstractGPs.GP object.
  • b0: The basis points (input locations) defining the reference distribution.
  • μ0: Initial mean vector at b0.
  • Σ0: Initial covariance matrix at b0, including the jitter $\varepsilon$.
  • Σ0⁻¹: Pre-computed inverse of Σ0, used for the interpolation weights $H(u)$.
  • R1: Process noise matrix (initialized to zeros, i.e. a function constant in time).
  • cache: A NamedTuple containing DiffCache arrays (from PreallocationTools.jl).

References

[1] M. F. Huber, "Recursive Gaussian process: On-line regression and learning," Pattern Recognition Letters, vol. 45, pp. 85-91, 2014, doi: 10.1016/j.patrec.2014.03.004

source

Constructors

RGP

There are three constructor overloads (docstrings are attached to each method):

SignatureDescription
RGP(gp, b0)Build from a full AbstractGPs.GP object
RGP(kernel, b0)Build from a kernel (zero mean prior)
RGP(mean, kernel, b0)Build from a mean function and kernel

All overloads accept an optional positional argument cov_jitter = 1e-6 for numerical stability when inverting $\Sigma_0$.

ExtendedKalmanFilter

LowLevelParticleFilters.ExtendedKalmanFilter — Method
ExtendedKalmanFilter(rgp::RGP; σn=0.0, ny=1, nu=1, p=(;), kwargs...)

Construct an ExtendedKalmanFilter for a single RGP model.

The state is the GP function values at the basis points b0. Dynamics is set to identity and the measurement model uses measurement_gp. The measurement noise is the residual variance of the GP, uncertainty_gp, plus the sensor noise variance σn^2.

Arguments

  • rgp: The RGP model.
  • σn: Standard deviation of the sensor noise. The default 0.0 treats the observations as noise-free.
  • ny, nu: Output and input dimensions.
  • p: Additional parameters merged into the filter's parameter tuple.
  • kwargs...: Forwarded to the base ExtendedKalmanFilter constructor.
source
LowLevelParticleFilters.ExtendedKalmanFilter — Method
ExtendedKalmanFilter(components, dynamics, measurement, R2; Ajac=nothing, Cjac=nothing, p=(;), ny=1, nu=1, kwargs...)

Construct an ExtendedKalmanFilter with a structured, named state representation.

The state is a ComponentVector formed by concatenating the μ0 vectors of each component. The initial covariance and process noise are block-diagonal matrices built from each component's Σ0 and R1. Each component is stored in the filter's parameter tuple under its key, alongside xid and Σid axes for slicing with state and covariance.

Arguments

  • components: A NamedTuple keyed by component ID. Each value must have fields μ0 (initial mean vector), Σ0 (initial covariance matrix), and R1 (process noise matrix). Typical values are RGP models, but any struct with these fields works.
  • dynamics: State transition function f(x, u, p, t).
  • measurement: Observation function h(x, u, p, t).
  • R2: Measurement noise covariance function R2(x, u, p, t).
  • Ajac, Cjac: Optional Jacobians (see base ExtendedKalmanFilter).
  • p: Additional parameters merged into the filter's parameter tuple.
  • ny, nu: Output and input dimensions.
  • kwargs...: Forwarded to the base ExtendedKalmanFilter constructor.
source

Inference and Prediction

RecursiveGPs.measurement_gp — Function
measurement_gp(rgp::RGP, g::AbstractArray, b::Real)

Mean of the function at input b, given the values g at the basis points:

\[\mathbb{E}[f(b) \mid g] = m(b) + H(b)\,(g - \mu_0), \qquad H(b) = K_{b b_0}\,\Sigma_0^{-1}\]

This is the measurement function of an RGP observation. See Function values from the basis values in the Mathematical Background.

source
RecursiveGPs.uncertainty_gp — Function
uncertainty_gp(rgp::RGP, b::Real)

Residual variance of the function at input b, given the values at the basis points:

\[r(b) = k(b, b) - H(b)\,K_{b_0 b}\]

It is zero at the basis points and grows between them. Add it to the sensor noise variance to obtain the measurement noise $R_2$ of an RGP observation. See Observation model in the Mathematical Background.

source
RecursiveGPs.predict_gp — Function
predict_gp(kf, b::AbstractVector, x = state(kf), P = covariance(kf))

Posterior of the function at the query points b, for a filter built with ExtendedKalmanFilter(rgp). With interpolation weights $H^* = K_{b b_0}\,\Sigma_0^{-1}$, filter mean $\hat g = x$ and covariance $P$:

\[\begin{aligned} \mu^* &= m(b) + H^*(\hat g - \mu_0) \\ \Sigma^* &= H^* P H^{*\top} + K_{bb} - H^* K_{b_0 b} \end{aligned}\]

The first term of $\Sigma^*$ is the uncertainty of the basis values, the second the residual between basis points. $\Sigma^*$ excludes sensor noise. See Prediction at new inputs in the Mathematical Background.

Returns a NamedTuple (; μ, Σ).

source
predict_gp(kf, b::AbstractVector, x::AbstractArray, P::AbstractMatrix, id::Symbol)

Posterior of the GP component id at the query points b, for a filter built with the multi-component constructor. x and P are the full filter mean and covariance; the block of component id is used, which gives its marginal posterior. The formulas are those of predict_gp for a single RGP.

Returns a NamedTuple (; μ, Σ).

source
predict_gp(kf, b::AbstractVector, id::Symbol)

Posterior of the GP component id at the query points b, using the current filter mean and covariance.

Returns a NamedTuple (; μ, Σ).

source
RecursiveGPs.predict_kf — Function
predict_kf(kf, u, x=state(kf), R=covariance(kf), p=kf.p, t=index(kf))

Calculate the predicted measurement and innovation covariance.

Arguments

  • kf: The Extended Kalman Filter.
  • u: The control input.
  • x: State estimate.
  • R: Covariance of the state estimate.
  • p: Additional parameters passed to the filter.
  • t: Current time index.

Returns

A named tuple (;μ, Σ) where:

  • μ: The predicted measurement $h(x, u, p, t)$.
  • Σ: The innovation covariance $C R C^\top + R_2$, with measurement Jacobian $C$.
source

State Accessors (multi-component models)

These methods extend the LowLevelParticleFilters accessors with a component-index overload. They are available after constructing a filter with the multi-component ExtendedKalmanFilter(components, ...) constructor.

LowLevelParticleFilters.covariance — Method
covariance(kf, id::Symbol)

Extracts the covariance sub-matrix of a specific sub-component id from the current filter covariance. Retrieves the diagonal block $Σ_{id, id}$ using the saved axes in the filter parameters.

source