# gpcovar

## Purpose

Calculate the covariance for a Gaussian Process.

## Synopsis

    cov = gpcovar(net, x)
    [cov, covf] = gpcovar(net, x)

## Description

`cov = gpcovar(net, x)` takes a Gaussian Process data structure `net` together with a matrix `x` of input vectors, and computes the covariance matrix `cov`. The inverse of this matrix is used when calculating the mean and variance of the predictions made by `net`.

`[cov, covf] = gpcovar(net, x)` also generates the covariance matrix due to the covariance function specified by `net.covarfn` as calculated by `gpcovarf`.

## Example

In the following example, the inverse covariance matrix is calculated for a set of training inputs `x` and is then passed to `gpfwd` so that predictions (with mean `ytest` and variance `sigsq`) can be made for the test inputs `xtest`.

    cninv = inv(gpcovar(net, x));
    [ytest, sigsq] = gpfwd(net, xtest, cninv);

## See Also

`gp`, `gppak`, `gpunpak`, `gpcovarp`, `gpcovarf`, `gpfwd`, `gperr`, `gpgrad`

Pages: Index

Copyright (c) Ian T Nabney (1996-9)