Skip to content

Base

StationaryKernel

StationaryKernel(active_dims=None, lengthscale=1.0, variance=1.0, n_dims=None, compute_engine=DenseKernelComputation())

Bases: AbstractKernel

Base class for stationary kernels.

Stationary kernels are a class of kernels that are invariant to translations in the input space. They can be isotropic or anisotropic, meaning that they can have a single lengthscale for all input dimensions or a different lengthscale for each input dimension.

Parameters:

  • active_dims (Union[list[int], slice, None], default: None ) –

    The indices of the input dimensions that the kernel operates on.

  • lengthscale (Union[LengthscaleCompatible, Variable[Lengthscale]], default: 1.0 ) –

    the lengthscale(s) of the kernel β„“. If a scalar or an array of length 1, the kernel is isotropic, meaning that the same lengthscale is used for all input dimensions. If an array with length > 1, the kernel is anisotropic, meaning that a different lengthscale is used for each input.

  • variance (Union[ScalarFloat, Variable[ScalarArray]], default: 1.0 ) –

    the variance of the kernel Οƒ.

  • n_dims (Union[int, None], default: None ) –

    The number of input dimensions. If lengthscale is an array, this argument is ignored.

  • compute_engine (AbstractKernelComputation, default: DenseKernelComputation() ) –

    The computation engine that the kernel uses to compute the covariance matrix.

spectral_density property

spectral_density

The spectral density of the kernel.

Returns:

  • Distribution –

    Callable[[Float[Array, "D"]], Float[Array, "D"]]: The spectral density function.

__call__ abstractmethod

__call__(x, y)

Evaluate the kernel on a pair of inputs.

Parameters:

  • x (Num[Array, ' D']) –

    the left hand input of the kernel function.

  • y (Num[Array, ' D']) –

    The right hand input of the kernel function.

Returns:

  • ScalarFloat –

    The evaluated kernel function at the supplied inputs.

cross_covariance

cross_covariance(x, y)

Compute the cross-covariance matrix of the kernel.

Parameters:

  • x (Num[Array, 'N D']) –

    the first input matrix of shape (N, D).

  • y (Num[Array, 'M D']) –

    the second input matrix of shape (M, D).

Returns:

  • Float[Array, 'N M'] –

    The cross-covariance matrix of the kernel of shape (N, M).

gram

gram(x)

Compute the gram matrix of the kernel.

Parameters:

  • x (Num[Array, 'N D']) –

    the input matrix of shape (N, D).

Returns:

  • LinearOperator –

    The gram matrix of the kernel of shape (N, N).

diagonal

diagonal(x)

Compute the diagonal of the gram matrix of the kernel.

Parameters:

  • x (Num[Array, 'N D']) –

    the input matrix of shape (N, D).

Returns:

  • Float[Array, ' N'] –

    The diagonal of the gram matrix of the kernel of shape (N,).

slice_input

slice_input(x)

Slice out the relevant columns of the input matrix.

Select the relevant columns of the supplied matrix to be used within the kernel's evaluation.

Parameters:

  • x (Float[Array, '... D']) –

    the matrix or vector that is to be sliced.

Returns:

  • Float[Array, '... Q'] –

    The sliced form of the input matrix.

__add__

__add__(other)

Add two kernels together. Args: other (AbstractKernel): The kernel to be added to the current kernel.

Returns:

  • AbstractKernel ( AbstractKernel ) –

    A new kernel that is the sum of the two kernels.

__mul__

__mul__(other)

Multiply two kernels together.

Parameters:

  • other (AbstractKernel) –

    The kernel to be multiplied with the current kernel.

Returns:

  • AbstractKernel ( AbstractKernel ) –

    A new kernel that is the product of the two kernels.