# Covariance Functions¶

 Constant valued covariance function. WhiteNoise(sigma) White noise covariance function. ExpQuad(input_dim[, ls, ls_inv, active_dims]) The Exponentiated Quadratic kernel. RatQuad(input_dim, alpha[, ls, ls_inv, ...]) The Rational Quadratic kernel. Matern32(input_dim[, ls, ls_inv, active_dims]) The Matern kernel with nu = 3/2. Matern52(input_dim[, ls, ls_inv, active_dims]) The Matern kernel with nu = 5/2. Exponential(input_dim[, ls, ls_inv, active_dims]) The Exponential kernel. Cosine(input_dim[, ls, ls_inv, active_dims]) The Cosine kernel. Periodic(input_dim, period[, ls, ls_inv, ...]) The Periodic kernel. Linear(input_dim, c[, active_dims]) The Linear kernel. Polynomial(input_dim, c, d, offset[, ...]) The Polynomial kernel. WarpedInput(input_dim, cov_func, warp_func) Warp the inputs of any kernel using an arbitrary function defined using Theano. Gibbs(input_dim, lengthscale_func[, args, ...]) The Gibbs kernel. Kron(factor_list) Form a covariance object that is the kronecker product of other covariances. Coregion(input_dim[, W, kappa, B, active_dims]) Covariance function for intrinsic/linear coregionalization models.
class pymc3.gp.cov.Constant(c)

Constant valued covariance function.

$k(x, x') = c$
class pymc3.gp.cov.Coregion(input_dim, W=None, kappa=None, B=None, active_dims=None)

This covariance has the form:

$\mathbf{B} = \mathbf{W}\mathbf{W}^\top + \text{diag}(\kappa)$

and calls must use integers associated with the index of the matrix. This allows the api to remain consistent with other covariance objects:

$k(x, x') = \mathbf{B}[x, x'^\top]$
Parameters
W: 2D array of shape (num_outputs, rank)

a low rank matrix that determines the correlations between the different outputs (rows)

kappa: 1D array of shape (num_outputs, )

a vector which allows the outputs to behave independently

B: 2D array of shape (num_outputs, rank)

the total matrix, exactly one of (W, kappa) and B must be provided

Notes

Exactly one dimension must be active for this kernel. Thus, if input_dim != 1, then active_dims must have a length of one.

class pymc3.gp.cov.Cosine(input_dim, ls=None, ls_inv=None, active_dims=None)

The Cosine kernel.

$k(x, x') = \mathrm{cos}\left( 2 \pi \frac{||x - x'||}{ \ell^2} \right)$

The Exponentiated Quadratic kernel. Also refered to as the Squared Exponential, or Radial Basis Function kernel.

$k(x, x') = \mathrm{exp}\left[ -\frac{(x - x')^2}{2 \ell^2} \right]$
class pymc3.gp.cov.Exponential(input_dim, ls=None, ls_inv=None, active_dims=None)

The Exponential kernel.

$k(x, x') = \mathrm{exp}\left[ -\frac{||x - x'||}{2\ell^2} \right]$
class pymc3.gp.cov.Gibbs(input_dim, lengthscale_func, args=None, active_dims=None)

The Gibbs kernel. Use an arbitrary lengthscale function defined using Theano. Only tested in one dimension.

$k(x, x') = \sqrt{\frac{2\ell(x)\ell(x')}{\ell^2(x) + \ell^2(x')}} \mathrm{exp}\left[ -\frac{(x - x')^2} {\ell^2(x) + \ell^2(x')} \right]$
Parameters
lengthscale_func: callable

Theano function of X and additional optional arguments.

args: optional, tuple or list of scalars or PyMC3 variables

Additional inputs (besides X or Xs) to lengthscale_func.

class pymc3.gp.cov.Kron(factor_list)

Form a covariance object that is the kronecker product of other covariances.

In contrast to standard multiplication, where each covariance is given the same inputs X and Xs, kronecker product covariances first split the inputs into their respective spaces (inferred from the input_dim of each object) before forming their product. Kronecker covariances have a larger input dimension than any of its factors since the inputs are the concatenated columns of its components.

Factors must be covariances or their combinations, arrays will not work.

Generally utilized by the gp.MarginalKron and gp.LatentKron` implementations.

class pymc3.gp.cov.Linear(input_dim, c, active_dims=None)

The Linear kernel.

$k(x, x') = (x - c)(x' - c)$
class pymc3.gp.cov.Matern32(input_dim, ls=None, ls_inv=None, active_dims=None)

The Matern kernel with nu = 3/2.

$k(x, x') = \left(1 + \frac{\sqrt{3(x - x')^2}}{\ell}\right) \mathrm{exp}\left[ - \frac{\sqrt{3(x - x')^2}}{\ell} \right]$
class pymc3.gp.cov.Matern52(input_dim, ls=None, ls_inv=None, active_dims=None)

The Matern kernel with nu = 5/2.

$k(x, x') = \left(1 + \frac{\sqrt{5(x - x')^2}}{\ell} + \frac{5(x-x')^2}{3\ell^2}\right) \mathrm{exp}\left[ - \frac{\sqrt{5(x - x')^2}}{\ell} \right]$
class pymc3.gp.cov.Periodic(input_dim, period, ls=None, ls_inv=None, active_dims=None)

The Periodic kernel.

$k(x, x') = \mathrm{exp}\left( -\frac{\mathrm{sin}^2(\pi |x-x'| \frac{1}{T})}{2\ell^2} \right)$

Notes

Note that the scaling factor for this kernel is different compared to the more common definition (see ). Here, 0.5 is in the exponent instead of the more common value, 2. Divide the length-scale by 2 when initializing the kernel to recover the standard definition.

References

1

David Duvenaud, “The Kernel Cookbook” https://www.cs.toronto.edu/~duvenaud/cookbook/

class pymc3.gp.cov.Polynomial(input_dim, c, d, offset, active_dims=None)

The Polynomial kernel.

$k(x, x') = [(x - c)(x' - c) + \mathrm{offset}]^{d}$
class pymc3.gp.cov.RatQuad(input_dim, alpha, ls=None, ls_inv=None, active_dims=None)

$k(x, x') = \left(1 + \frac{(x - x')^2}{2\alpha\ell^2} \right)^{-\alpha}$
class pymc3.gp.cov.ScaledCov(input_dim, cov_func, scaling_func, args=None, active_dims=None)

Construct a kernel by multiplying a base kernel with a scaling function defined using Theano. The scaling function is non-negative, and can be parameterized.

$k(x, x') = \phi(x) k_{\text{base}}(x, x') \phi(x')$
Parameters
cov_func: Covariance

Base kernel or covariance function

scaling_func: callable

Theano function of X and additional optional arguments.

args: optional, tuple or list of scalars or PyMC3 variables

Additional inputs (besides X or Xs) to lengthscale_func.

class pymc3.gp.cov.WarpedInput(input_dim, cov_func, warp_func, args=None, active_dims=None)

Warp the inputs of any kernel using an arbitrary function defined using Theano.

$k(x, x') = k(w(x), w(x'))$
Parameters
cov_func: Covariance
warp_func: callable

Theano function of X and additional optional arguments.

args: optional, tuple or list of scalars or PyMC3 variables

Additional inputs (besides X or Xs) to warp_func.

class pymc3.gp.cov.WhiteNoise(sigma)

White noise covariance function.

$k(x, x') = \sigma^2 \mathrm{I}$