Cholesky#

class tinygp.transforms.Cholesky(factor: JAXArray, kernel: Kernel)[source]#

Bases: Kernel

Apply a Cholesky transformation to the input coordinates of the kernel

For example, the following transformed kernels are all equivalent, but the second supports more flexible transformations:

>>> import numpy as np
>>> from tinygp import kernels, transforms
>>> kernel0 = kernels.Matern32(4.5)
>>> kernel1 = transforms.Cholesky(4.5, kernels.Matern32())
>>> np.testing.assert_allclose(
...     kernel0.evaluate(0.5, 0.1), kernel1.evaluate(0.5, 0.1)
... )
Parameters:
  • factor (JAXArray) – A 0-, 1-, or 2-dimensional array specifying the Cholesky factor. If 2-dimensional, this must be a lower triangular matrix, but this is not checked.

  • kernel (Kernel) – The kernel to use in the transformed space.

evaluate(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) tinygp.helpers.JAXArray[source]#

Evaluate the kernel at a pair of input coordinates

This should be overridden be subclasses to return the kernel-specific value. Two things to note:

  1. Users shouldn’t generally call Kernel.evaluate(). Instead, always “call” the kernel instance directly; for example, you can evaluate the Matern-3/2 kernel using Matern32(1.5)(x1, x2), for arrays of input coordinates x1 and x2.

  2. When implementing a custom kernel, this method should treat X1 and X2 as single datapoints. In other words, these inputs will typically either be scalars of have shape n_dim, where n_dim is the number of input dimensions, rather than n_data or (n_data, n_dim), and you should let the Kernel vmap magic handle all the broadcasting for you.

evaluate_diag(X: tinygp.helpers.JAXArray) tinygp.helpers.JAXArray#

Evaluate the kernel on its diagonal

The default implementation simply calls Kernel.evaluate() with X as both arguments, but subclasses can use this to make diagonal calcuations more efficient.

classmethod from_parameters(diagonal: tinygp.helpers.JAXArray, off_diagonal: tinygp.helpers.JAXArray, kernel: Kernel) Cholesky[source]#

Build a Cholesky transform with a sensible parameterization

Parameters:
  • diagonal (JAXArray) – An (ndim,) array with the diagonal elements of factor. These must be positive, but this is not checked.

  • off_diagonal (JAXArray) – An ((ndim - 1) * ndim,) array with the off-diagonal elements of factor.

  • kernel (Kernel) – The kernel to use in the transformed space.