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_params — Function
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.
This function returns a tuple (kernel_fn, θ_init, dim_θ) where:
kernel_fn(θ)returns aKernelFunctions.Kernelinstance parameterised byθ.θ_initis a vector of initial hyperparameters (in softplus-transformed space).dim_θis the total number of hyperparameters.
Supported kernel families:
kernel_spec | Description | Parameters per component |
|---|---|---|
:SE | Single squared-exponential | 1 + D (variance + lengthscales) or 2 (shared lengthscale) |
:SEn | Sum of num_SE SE kernels | num_SE × (1 + D) or num_SE × 2 |
:SMn | Sum of num_SM spectral-mixture components | num_SM × (1 + 2D) |
:SEn_SMn | Sum of SE and SM components | Combined |
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_fn — Function
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.
RxGP.get_gradient_Kxx_fn — Function
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.
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:
| Mode | Description | Supported kernels |
|---|---|---|
:AD | Automatic differentiation via ForwardDiff.jl | All kernel families |
:AN | Analytic closed-form expressions (~10× faster) | :SE, :SEn only |