mixle.models._kernels module¶
Shared NumPy stationary-kernel primitives (RBF / Matern-3/2 / Matern-5/2).
The RBF and Matern covariance shapes were re-implemented independently in several places
(mixle.models.sparse_gaussian_process, mixle.ppl.field, mixle.doe.calibrate),
each with its own sqrt(3)/sqrt(5) constants. This module is the single source of those shapes
for the NumPy back-end. (The Torch GP in mixle.models.gaussian_process keeps its own autograd
kernel – a real back-end difference, not duplication that can be shared here.)
Two layers are provided:
shape functions that take an already-lengthscale-scaled distance and return
amp**2 * shape– these let callers keep whatever distance/scaling arithmetic they already use (e.g. great-circle chord distance, or scaling the squared distance before vs after the sqrt), so existing numerical results are preserved bit-for-bit;stationary_kernel(), a self-contained(x1, x2, lengthscale, amplitude, name)helper that computes Euclidean pairwise distances and applies the chosen shape (the sparse-GP convention: scale the squared distance bylengthscale**2before the sqrt).
None of these add a jitter / nugget term – that is a caller concern (the existing call sites use different nugget values: 1e-8 on Kuu, 1e-6 on a field covariance, none on a cross-covariance), so it stays at the call site.
- rbf_from_scaled_sqdist(d2_scaled, amplitude)[source]
RBF (squared-exponential) covariance
amp**2 * exp(-0.5 * d2_scaled).d2_scaledis the squared distance already divided bylengthscale**2.
- matern32_from_scaled_dist(r, amplitude)[source]
Matern-3/2 covariance
amp**2 * (1 + s) * exp(-s)withs = sqrt(3) * r.ris the Euclidean distance already divided by the lengthscale.
- matern52_from_scaled_dist(r, amplitude)[source]
Matern-5/2 covariance
amp**2 * (1 + s + s**2/3) * exp(-s)withs = sqrt(5) * r.ris the Euclidean distance already divided by the lengthscale.
- exponential_from_scaled_dist(r, amplitude)[source]
Matern-1/2 / exponential covariance
amp**2 * exp(-r)(ralready lengthscale-scaled).
- stationary_kernel(x1, x2, lengthscale, amplitude, name)[source]
Pairwise stationary covariance between point sets
x1andx2(Euclidean inputs).nameis'rbf','matern32'or'matern52'. The squared distance is divided bylengthscale**2before the (Matern) sqrt – the sparse-GP convention – with the Matern sqrt floored at1e-12so it stays defined at zero separation. No jitter is added.