kernels package#

The primary model building interface in tinygp is via “kernels”, which are typically constructed as sums and products of objects defined in this subpackage, or by subclassing Kernel as discussed in the Custom Kernels tutorial. Many of the most commonly used kernels are described in the Stationary Kernels section, but this section introduces some of the fundamental building blocks.


The base class for all kernel implementations

Conditioned(X, solver, kernel)

A kernel used when conditioning a process on data


A custom kernel class implemented as a callable

Sum(kernel1, kernel2)

A helper to represent the sum of two kernels

Product(kernel1, kernel2)

A helper to represent the product of two kernels


This kernel returns the constant


The dot product kernel

Polynomial(order, scale, sigma)

A polynomial kernel

Stationary Kernels#

Many of the most commonly used kernels are implemented as subclasses of the Stationary kernel. This means that each kernel in this section has (at least) the two parameters:

  • scale: A scalar lengthscale for the kernel in the radial distance specified by distance, and

  • distance: A tinygp.kernels.distance.Distance metric specifying how to compute the scalar distance between two input coordinates.

Most of these kernels use the tinygp.kernels.distance.L1Distance metric by default, and scale defaults to 1.

Stationary(scale, distance)

A stationary kernel is defined with respect to a distance metric

Exp(scale, distance)

The exponential kernel

ExpSquared(scale, distance)

The exponential squared or radial basis function kernel

Matern32(scale, distance)

The Matern-3/2 kernel

Matern52(scale, distance)

The Matern-5/2 kernel

Cosine(scale, distance)

The cosine kernel

ExpSineSquared(scale, distance, gamma)

The exponential sine squared or quasiperiodic kernel

RationalQuadratic(scale, distance, alpha)

The rational quadratic

Distance Metrics#

This submodule defines a set of distance metrics that can be used when working with multivariate data. By default, all tinygp.kernels.stationary.Stationary kernels will use either an L1Distance or L2Distance, when applied in multiple dimensions, but it is possible to define custom metrics, as discussed in the Custom Geometry tutorial.


An abstract base class defining a distance metric interface


The L1 or Manhattan distance between two coordinates


The L2 or Euclidean distance between two coordinates