Bases: probnum.kernels.Kernel

Covariance function defined by $$k(x_0, x_1) = \big(1 + \frac{\lVert x_0 - x_1 \rVert^2}{2\alpha l^2}\big)^{-\alpha}$$, where $$\alpha > 0$$. For $$\alpha \rightarrow \infty$$ the rational quadratic kernel converges to the ExpQuad kernel.

Parameters
• input_dim (Integral) – Input dimension of the kernel.

• lengthscale (Number) – Lengthscale of the kernel. Describes the input scale on which the process varies.

• alpha (Number) – Scale mixture. Positive constant determining the weighting between different lengthscales.

Examples

>>> import numpy as np
>>> K = RatQuad(input_dim=1, lengthscale=0.1, alpha=3)
>>> K(np.linspace(0, 1, 3)[:, None])
array([[1.00000000e+00, 7.25051190e-03, 1.81357765e-04],
[7.25051190e-03, 1.00000000e+00, 7.25051190e-03],
[1.81357765e-04, 7.25051190e-03, 1.00000000e+00]])

Attributes Summary

 input_dim Dimension of arguments of the covariance function. output_dim Dimension of the evaluated covariance function.

Methods Summary

 __call__(x0[, x1]) Evaluate the kernel.

Attributes Documentation

input_dim

Dimension of arguments of the covariance function.

The dimension of inputs to the covariance function $$k : \mathbb{R}^{ d_{in}} \times \mathbb{R}^{d_{in}} \rightarrow \mathbb{R}^{d_{out} \times d_{out}}$$.

Return type

int

output_dim

Dimension of the evaluated covariance function.

The resulting evaluated kernel $$k(x_0, x_1) \in \mathbb{R}^{d_{out} \times d_{out}}$$ has shape=(output_dim, output_dim).

Return type

int

Methods Documentation

__call__(x0, x1=None)[source]

Evaluate the kernel.

Computes the covariance function at x0 and x1. If the inputs have more than one dimension the covariance function is evaluated pairwise for all observations determined by the first dimension of x0 and x1. If only x0 is given the kernel matrix $$K=k(X_0, X_0)$$ is computed.

Parameters
• x0 (ndarray) – shape=(input_dim,) or (n0, input_dim) – First input.

• x1 (Optional[ndarray]) – shape=(input_dim,) or (n1, input_dim) – Second input.

Returns

shape=(), (output_dim, output_dim) or (n0, n1) or (n0, n1, output_dim, output_dim) – Kernel evaluated at x0 and x1 or kernel matrix containing pairwise evaluations for all observations in x0 (and x1).

Return type

cov