ogpcovarf

Purpose

Calculate the covariance function for the OGP.

Synopsis

covf = ogpcovarf(x1, x2)

Description

covf = ogpcovarf(x1, x2) considers the global OGP data structure net together with two matrices x1, x2 and computes the matrix of covariance function covf. If called with a single input x1, the function returns only the diagonal of ogpcovarf(x1,x1).

If the output is not one-dimensional, then the returned matrix has nout times the lenght of the inputs x1 and x2 respectively. Using a single input set gives the covariance function as dim(x1),nout,nout three dimensional matrix.

The scalar product (or distances) between inputs x1 and x2 are computed using the scaling from exp(net.kpar(1:net.nin)). For all covariance types there is an amplitude exp(net.kpar(net.nin+1)). Other kernel-specific parameters can be specified at higher positions: net.kpar(net.nin+2) and above. The number of parameters in the kernel function can be arbitrarily high.

The available kernel functions are the following:

'sqexp'

- squared exponential.

'polyexp'

- polynomial exponential kernel. A product of the exponential and the polynomial kernels.

'ratquad'

- rational quadtratic kernel. The order of the kernel function is net.kpar(2).

'poly'

- polynomial kernel. The order of the polynomial is exp(net.kpar(2)).

'linspline'

- linear spline kernel.

'sinc'

- the sinc kernel with frequency cutoff at exp(net.kpar(2)).

'fsin'

- the fsin kernel used in density estimation.

'user'

- user-specified kernel function.

If the user-specified covariance function is used, i.e. net.covarfn='user', net.kpar still contains the hyperparameters - the parameters of the kernel, but there are two additional fields in the GLOBAL structure net:

kfnaddr

- the address of the function that returns the covariance kernel.

gradkaddr

- the address of the function returning the gradient of the kernel w.r.to the kernel parameters.

An example is cov_matern which implements the Matern covariance function.

Description of kernel functions

In all cases the inputs are rescaled. The input weights exp(net.kpar(1:net.nin)) are the diagonal elements of the metric, ie. the input is scaled with the square root of the weights before any operations are made.

If the multiplicative prefactor exp(net.kpar(net.nin+1)) is denoted with 'A' and net.kpar(net.nin+2) with nu, then the kernels are computed as follows:

'sqexp':

K(x,y) = A * exp( -|x-y|^2 /2)

'polyexp':

K(x,y) = A * (1+|x-y|)^p * exp( -|x-y|^2 /2)

'ratquad':

K(x,y) = A * ( 1 + |x-y|^2)^(-nu)

'poly':

K(x,y) = A * ( 1 + x^T * y )^nu

'linspline'

for positive inputs (for multidimensional inputs the results from the one-dimensional case are added):

K(x,y) = A * (min(x,y)^3/3 + min(x,y)^2*abs(x-y)/2 + x*y + 1)

'sinc'

for the multidimensional case the results are added (the prefactors 'A' can differ for each input dimension):

K(x,y) = A * sinc( (x-y) )

'fsin'

where (x-y) is rescaled to [0,1]:

K(x,y) = A * (-cos(2*pi*nu(x-y))+sin(2*pi*nu*(x-y)))*cotg(pi*(x-y))

'user'

- the covariance function specified by the user. It references an external function at the address net.kfnaddr which The field net.kpar.fnaddr has the address of the function that computes the kernel. The function has the syntax:

covf = FNAME(x1,x2)

and the parameters are from net.kpar. Called with a single argument, the function should return only the diagonal of the kernel matrix (speedup of the computation). If hyperparameter optimisation is aimed, then the structure net.gradkaddr which returns the gradient of the kernel function with respect to the kernel parameters. An example is implemented in covgrad_matern, see the documentation and source from there.

As an example, the Matern covariance function is presented in cov_matern. See the documentation of the matern covariance kernel for a description and the Matlab code for details.

See Also

ogp, ogpinit, ogpcovarp, ogpcovdiag, cov_matern


Pages: Index

Copyright (c) Lehel Csató (2001-2004)