Skip to contents

Computes a linear kernel from inner products between observations.

Usage

kernel_linear(x, y = NULL, variance = 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.

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

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

Examples

x <- cbind(c(1, 2, 3), c(0, 1, 0))
kernel_linear(x, variance = 0.5)
#>      [,1] [,2] [,3]
#> [1,]  0.5  1.0  1.5
#> [2,]  1.0  2.5  3.0
#> [3,]  1.5  3.0  4.5