5.12 Covariance Functions

5.12.1 Exponentiated quadratic covariance function

The exponentiated quadratic kernel defines the covariance between \(f(x_i)\) and \(f(x_j)\) where \(f\colon \mathbb{R}^D \mapsto \mathbb{R}\) as a function of the squared Euclidian distance between \(x_i \in \mathbb{R}^D\) and \(x_j \in \mathbb{R}^D\): \[ \text{cov}(f(x_i), f(x_j)) = k(x_i, x_j) = \alpha^2 \exp \left( - \dfrac{1}{2\rho^2} \sum_{d=1}^D (x_{i,d} - x_{j,d})^2 \right) \] with \(\alpha\) and \(\rho\) constrained to be positive.

There are two variants of the exponentiated quadratic covariance function in Stan. One builds a covariance matrix, \(K \in \mathbb{R}^{N \times N}\) for \(x_1, \dots, x_N\), where \(K_{i,j} = k(x_i, x_j)\), which is necessarily symmetric and positive semidefinite by construction. There is a second variant of the exponentiated quadratic covariance function that builds a \(K \in \mathbb{R}^{N \times M}\) covariance matrix for \(x_1, \dots, x_N\) and \(x^\prime_1, \dots, x^\prime_M\), where \(x_i \in \mathbb{R}^D\) and \(x^\prime_i \in \mathbb{R}^D\) and \(K_{i,j} = k(x_i, x^\prime_j)\).

matrix cov_exp_quad(row_vectors x, real alpha, real rho)
The covariance matrix with an exponentiated quadratic kernel of x.

matrix cov_exp_quad(vectors x, real alpha, real rho)
The covariance matrix with an exponentiated quadratic kernel of x.

matrix cov_exp_quad(real[] x, real alpha, real rho)
The covariance matrix with an exponentiated quadratic kernel of x.

matrix cov_exp_quad(row_vectors x1, row_vectors x2, real alpha, real rho)
The covariance matrix with an exponentiated quadratic kernel of x1 and x2.

matrix cov_exp_quad(vectors x1, vectors x2, real alpha, real rho)
The covariance matrix with an exponentiated quadratic kernel of x1 and x2.

matrix cov_exp_quad(real[] x1, real[] x2, real alpha, real rho)
The covariance matrix with an exponentiated quadratic kernel of x1 and x2.