wolffd@0: function [cov, covf] = gpcovar(net, x) wolffd@0: %GPCOVAR Calculate the covariance for a Gaussian Process. wolffd@0: % wolffd@0: % Description wolffd@0: % wolffd@0: % COV = GPCOVAR(NET, X) takes a Gaussian Process data structure NET wolffd@0: % together with a matrix X of input vectors, and computes the wolffd@0: % covariance matrix COV. The inverse of this matrix is used when wolffd@0: % calculating the mean and variance of the predictions made by NET. wolffd@0: % wolffd@0: % [COV, COVF] = GPCOVAR(NET, X) also generates the covariance matrix wolffd@0: % due to the covariance function specified by NET.COVARFN as calculated wolffd@0: % by GPCOVARF. wolffd@0: % wolffd@0: % See also wolffd@0: % GP, GPPAK, GPUNPAK, GPCOVARP, GPCOVARF, GPFWD, GPERR, GPGRAD wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: wolffd@0: % Check arguments for consistency wolffd@0: errstring = consist(net, 'gp', x); wolffd@0: if ~isempty(errstring); wolffd@0: error(errstring); wolffd@0: end wolffd@0: wolffd@0: ndata = size(x, 1); wolffd@0: wolffd@0: % Compute prior covariance wolffd@0: if nargout >= 2 wolffd@0: [covp, covf] = gpcovarp(net, x, x); wolffd@0: else wolffd@0: covp = gpcovarp(net, x, x); wolffd@0: end wolffd@0: wolffd@0: % Add output noise variance wolffd@0: cov = covp + (net.min_noise + exp(net.noise))*eye(ndata); wolffd@0: