## 6.13 Gaussian Process Covariance Functions

The Gaussian process covariance functions compute the covariance between observations in an input data set or the cross-covariance between two input data sets.

For one dimensional GPs, the input data sets are arrays of scalars. The covariance matrix is given by $$K_{ij} = k(x_i, x_j)$$ (where $$x_i$$ is the $$i^{th}$$ element of the array $$x$$) and the cross-covariance is given by $$K_{ij} = k(x_i, y_j)$$.

For multi-dimensional GPs, the input data sets are arrays of vectors. The covariance matrix is given by $$K_{ij} = k(\mathbf{x}_i, \mathbf{x}_j)$$ (where $$\mathbf{x}_i$$ is the $$i^{th}$$ vector in the array $$x$$) and the cross-covariance is given by $$K_{ij} = k(\mathbf{x}_i, \mathbf{y}_j)$$.

With magnitude $$\sigma$$ and length scale $$l$$, the exponentiated quadratic kernel is:

$k(\mathbf{x}_i, \mathbf{x}_j) = \sigma^2 \exp \left( -\frac{|\mathbf{x}_i - \mathbf{x}_j|^2}{2l^2} \right)$

matrix gp_exp_quad_cov(array[] real x, real sigma, real length_scale)

Gaussian process covariance with exponentiated quadratic kernel in one dimension.
Available since 2.20

matrix gp_exp_quad_cov(array[] real x1, array[] real x2, real sigma, real length_scale)

Gaussian process cross-covariance of x1 and x2 with exponentiated quadratic kernel in one dimension.
Available since 2.20

matrix gp_exp_quad_cov(vectors x, real sigma, real length_scale)

Gaussian process covariance with exponentiated quadratic kernel in multiple dimensions.
Available since 2.20

matrix gp_exp_quad_cov(vectors x, real sigma, array[] real length_scale)

Gaussian process covariance with exponentiated quadratic kernel in multiple dimensions with a length scale for each dimension.
Available since 2.20

matrix gp_exp_quad_cov(vectors x1, vectors x2, real sigma, real length_scale)

Gaussian process cross-covariance of x1 and x2 with exponentiated quadratic kernel in multiple dimensions.
Available since 2.20

matrix gp_exp_quad_cov(vectors x1, vectors x2, real sigma, array[] real length_scale)

Gaussian process cross-covariance of x1 and x2 with exponentiated quadratic kernel in multiple dimensions with a length scale for each dimension.
Available since 2.20

### 6.13.2 Dot product kernel

With bias $$\sigma_0$$ the dot product kernel is:

$k(\mathbf{x}_i, \mathbf{x}_j) = \sigma_0^2 + \mathbf{x}_i^T \mathbf{x}_j$

matrix gp_dot_prod_cov(array[] real x, real sigma)

Gaussian process covariance with dot product kernel in one dimension.
Available since 2.20

matrix gp_dot_prod_cov(array[] real x1, array[] real x2, real sigma)

Gaussian process cross-covariance of x1 and x2 with dot product kernel in one dimension.
Available since 2.20

matrix gp_dot_prod_cov(vectors x, real sigma)

Gaussian process covariance with dot product kernel in multiple dimensions.
Available since 2.20

matrix gp_dot_prod_cov(vectors x1, vectors x2, real sigma)

Gaussian process cross-covariance of x1 and x2 with dot product kernel in multiple dimensions.
Available since 2.20

### 6.13.3 Exponential kernel

With magnitude $$\sigma$$ and length scale $$l$$, the exponential kernel is:

$k(\mathbf{x}_i, \mathbf{x}_j) = \sigma^2 \exp \left( -\frac{|\mathbf{x}_i - \mathbf{x}_j|}{l} \right)$

matrix gp_exponential_cov(array[] real x, real sigma, real length_scale)

Gaussian process covariance with exponential kernel in one dimension.
Available since 2.20

matrix gp_exponential_cov(array[] real x1, array[] real x2, real sigma, real length_scale)

Gaussian process cross-covariance of x1 and x2 with exponential kernel in one dimension.
Available since 2.20

matrix gp_exponential_cov(vectors x, real sigma, real length_scale)

Gaussian process covariance with exponential kernel in multiple dimensions.
Available since 2.20

matrix gp_exponential_cov(vectors x, real sigma, array[] real length_scale)

Gaussian process covariance with exponential kernel in multiple dimensions with a length scale for each dimension.
Available since 2.20

matrix gp_exponential_cov(vectors x1, vectors x2, real sigma, real length_scale)

Gaussian process cross-covariance of x1 and x2 with exponential kernel in multiple dimensions.
Available since 2.20

matrix gp_exponential_cov(vectors x1, vectors x2, real sigma, array[] real length_scale)

Gaussian process cross-covariance of x1 and x2 with exponential kernel in multiple dimensions with a length scale for each dimension.
Available since 2.20

### 6.13.4 Matern 3/2 kernel

With magnitude $$\sigma$$ and length scale $$l$$, the Matern 3/2 kernel is:

$k(\mathbf{x}_i, \mathbf{x}_j) = \sigma^2 \left( 1 + \frac{\sqrt{3}|\mathbf{x}_i - \mathbf{x}_j|}{l} \right) \exp \left( -\frac{\sqrt{3}|\mathbf{x}_i - \mathbf{x}_j|}{l} \right)$

matrix gp_matern32_cov(array[] real x, real sigma, real length_scale)

Gaussian process covariance with Matern 3/2 kernel in one dimension.
Available since 2.20

matrix gp_matern32_cov(array[] real x1, array[] real x2, real sigma, real length_scale)

Gaussian process cross-covariance of x1 and x2 with Matern 3/2 kernel in one dimension.
Available since 2.20

matrix gp_matern32_cov(vectors x, real sigma, real length_scale)

Gaussian process covariance with Matern 3/2 kernel in multiple dimensions.
Available since 2.20

matrix gp_matern32_cov(vectors x, real sigma, array[] real length_scale)

Gaussian process covariance with Matern 3/2 kernel in multiple dimensions with a length scale for each dimension.
Available since 2.20

matrix gp_matern32_cov(vectors x1, vectors x2, real sigma, real length_scale)

Gaussian process cross-covariance of x1 and x2 with Matern 3/2 kernel in multiple dimensions.
Available since 2.20

matrix gp_matern32_cov(vectors x1, vectors x2, real sigma, array[] real length_scale)

Gaussian process cross-covariance of x1 and x2 with Matern 3/2 kernel in multiple dimensions with a length scale for each dimension.
Available since 2.20

### 6.13.5 Matern 5/2 kernel

With magnitude $$\sigma$$ and length scale $$l$$, the Matern 5/2 kernel is:

$k(\mathbf{x}_i, \mathbf{x}_j) = \sigma^2 \left( 1 + \frac{\sqrt{5}|\mathbf{x}_i - \mathbf{x}_j|}{l} + \frac{5 |\mathbf{x}_i - \mathbf{x}_j|^2}{3l^2} \right) \exp \left( -\frac{\sqrt{5} |\mathbf{x}_i - \mathbf{x}_j|}{l} \right)$

matrix gp_matern52_cov(array[] real x, real sigma, real length_scale)

Gaussian process covariance with Matern 5/2 kernel in one dimension.
Available since 2.20

matrix gp_matern52_cov(array[] real x1, array[] real x2, real sigma, real length_scale)

Gaussian process cross-covariance of x1 and x2 with Matern 5/2 kernel in one dimension.
Available since 2.20

matrix gp_matern52_cov(vectors x, real sigma, real length_scale)

Gaussian process covariance with Matern 5/2 kernel in multiple dimensions.
Available since 2.20

matrix gp_matern52_cov(vectors x, real sigma, array[] real length_scale)

Gaussian process covariance with Matern 5/2 kernel in multiple dimensions with a length scale for each dimension.
Available since 2.20

matrix gp_matern52_cov(vectors x1, vectors x2, real sigma, real length_scale)

Gaussian process cross-covariance of x1 and x2 with Matern 5/2 kernel in multiple dimensions.
Available since 2.20

matrix gp_matern52_cov(vectors x1, vectors x2, real sigma, array[] real length_scale)

Gaussian process cross-covariance of x1 and x2 with Matern 5/2 kernel in multiple dimensions with a length scale for each dimension.
Available since 2.20

### 6.13.6 Periodic kernel

With magnitude $$\sigma$$, length scale $$l$$, and period $$p$$, the periodic kernel is:

$k(\mathbf{x}_i, \mathbf{x}_j) = \sigma^2 \exp \left(-\frac{2 \sin^2 \left( \pi \frac{|\mathbf{x}_i - \mathbf{x}_j|}{p} \right) }{l^2} \right)$

matrix gp_periodic_cov(array[] real x, real sigma, real length_scale, real period)

Gaussian process covariance with periodic kernel in one dimension.
Available since 2.20

matrix gp_periodic_cov(array[] real x1, array[] real x2, real sigma, real length_scale, real period)

Gaussian process cross-covariance of x1 and x2 with periodic kernel in one dimension.
Available since 2.20

matrix gp_periodic_cov(vectors x, real sigma, real length_scale, real period)

Gaussian process covariance with periodic kernel in multiple dimensions.
Available since 2.20

matrix gp_periodic_cov(vectors x1, vectors x2, real sigma, real length_scale, real period)

Gaussian process cross-covariance of x1 and x2 with periodic kernel in multiple dimensions with a length scale for each dimension.
Available since 2.20