Kernel specification

RxGP builds on KernelFunctions.jl and provides utilities for constructing parameterised kernels, computing their gradient and Hessian operators, and initialising hyperparameters.

Building a kernel

RxGP.get_simple_kernel_and_paramsFunction
get_simple_kernel_and_params(D; kernel_spec=:SE, num_SE=1, num_SM=1, independent_SE_lengthscales=true)

Return (kernel_fn, θ_init, dim_θ) for a parameterised kernel in input dimension D.

Supported kernel_spec values: :SE, :SEn, :SMn, :SEn_SMn.

source

This function returns a tuple (kernel_fn, θ_init, dim_θ) where:

  • kernel_fn(θ) returns a KernelFunctions.Kernel instance parameterised by θ.
  • θ_init is a vector of initial hyperparameters (in softplus-transformed space).
  • dim_θ is the total number of hyperparameters.

Supported kernel families:

kernel_specDescriptionParameters per component
:SESingle squared-exponential1 + D (variance + lengthscales) or 2 (shared lengthscale)
:SEnSum of num_SE SE kernelsnum_SE × (1 + D) or num_SE × 2
:SMnSum of num_SM spectral-mixture componentsnum_SM × (1 + 2D)
:SEn_SMnSum of SE and SM componentsCombined

The independent_SE_lengthscales flag controls whether each input dimension gets its own lengthscale (true, default) or all dimensions share one (false).

Gradient and Hessian kernel functions

For derivative observation models (:grad and :joint_fn_grad operators), RxGP needs the gradient and Hessian of the kernel with respect to the input:

RxGP.get_gradient_Kxu_fnFunction
get_gradient_Kxu_fn(D; kernel, kernel_spec=:SE, mode=:AD, independent_SE_lengthscales=true)

Return a function (x, θ, Xu) -> Matrix that computes the gradient of the cross-kernel $\nabla_x k(x, X_u)$ (a D×M matrix). Supports :AD (autodiff) and :AN (analytic, SE only) modes.

source
RxGP.get_gradient_Kxx_fnFunction
get_gradient_Kxx_fn(D; kernel, kernel_spec=:SE, mode=:AD, independent_SE_lengthscales=true)

Return a function (x, θ) -> Matrix that computes the Hessian of the auto-kernel $\nabla_x \nabla_{x'} k(x, x')$ (a D×D matrix). Supports :AD and :AN modes.

source

These are called internally by get_UniSGPMeta when operator is :grad or :joint_fn_grad. You only need to call them directly for advanced custom setups.

Modes:

ModeDescriptionSupported kernels
:ADAutomatic differentiation via ForwardDiff.jlAll kernel families
:ANAnalytic closed-form expressions (~10× faster):SE, :SEn only