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