Skip to contents

The rational-quadratic kernel can be interpreted as a scale mixture of squared-exponential kernels with different length scales. Scalar and ARD length-scale parameterizations are both supported.

Usage

kernel_rational_quadratic(
  x,
  y = NULL,
  variance = 1,
  length_scale = 1,
  alpha = 1
)

Arguments

x

Numeric vector or matrix. Matrix rows are observations and columns are input dimensions.

y

Optional numeric vector or matrix with the same number of input dimensions as x. If NULL, computes the covariance of x with itself.

variance

Positive marginal variance.

length_scale

Positive scalar or numeric vector with one value per input dimension. A vector enables ARD.

alpha

Positive scale-mixture parameter.

Value

A numeric covariance matrix.

Stability

Stable: from version 1.0.0 this interface changes incompatibly only in a major release, after a deprecation period. Results and options that concern an experimental model class, kernel, or argument follow that interface's tier. See gaussianprocesses-package for the policy.

See also

rational_quadratic_kernel() creates the same kernel as a reusable specification, which can be combined, optimized, and used in models.

Examples

x <- seq(0, 2, by = 0.5)
kernel_rational_quadratic(x, length_scale = 0.7, alpha = 0.5)
#>           [,1]      [,2]      [,3]      [,4]      [,5]
#> [1,] 1.0000000 0.8137335 0.5734623 0.4228855 0.3303504
#> [2,] 0.8137335 1.0000000 0.8137335 0.5734623 0.4228855
#> [3,] 0.5734623 0.8137335 1.0000000 0.8137335 0.5734623
#> [4,] 0.4228855 0.5734623 0.8137335 1.0000000 0.8137335
#> [5,] 0.3303504 0.4228855 0.5734623 0.8137335 1.0000000

# As alpha grows, the kernel approaches the RBF kernel.
all.equal(
  kernel_rational_quadratic(x, alpha = 1e6),
  kernel_rbf(x),
  tolerance = 1e-5
)
#> [1] TRUE