annotate toolboxes/FullBNT-1.0.7/netlab3.3/gpcovar.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function [cov, covf] = gpcovar(net, x)
wolffd@0 2 %GPCOVAR Calculate the covariance for a Gaussian Process.
wolffd@0 3 %
wolffd@0 4 % Description
wolffd@0 5 %
wolffd@0 6 % COV = GPCOVAR(NET, X) takes a Gaussian Process data structure NET
wolffd@0 7 % together with a matrix X of input vectors, and computes the
wolffd@0 8 % covariance matrix COV. The inverse of this matrix is used when
wolffd@0 9 % calculating the mean and variance of the predictions made by NET.
wolffd@0 10 %
wolffd@0 11 % [COV, COVF] = GPCOVAR(NET, X) also generates the covariance matrix
wolffd@0 12 % due to the covariance function specified by NET.COVARFN as calculated
wolffd@0 13 % by GPCOVARF.
wolffd@0 14 %
wolffd@0 15 % See also
wolffd@0 16 % GP, GPPAK, GPUNPAK, GPCOVARP, GPCOVARF, GPFWD, GPERR, GPGRAD
wolffd@0 17 %
wolffd@0 18
wolffd@0 19 % Copyright (c) Ian T Nabney (1996-2001)
wolffd@0 20
wolffd@0 21 % Check arguments for consistency
wolffd@0 22 errstring = consist(net, 'gp', x);
wolffd@0 23 if ~isempty(errstring);
wolffd@0 24 error(errstring);
wolffd@0 25 end
wolffd@0 26
wolffd@0 27 ndata = size(x, 1);
wolffd@0 28
wolffd@0 29 % Compute prior covariance
wolffd@0 30 if nargout >= 2
wolffd@0 31 [covp, covf] = gpcovarp(net, x, x);
wolffd@0 32 else
wolffd@0 33 covp = gpcovarp(net, x, x);
wolffd@0 34 end
wolffd@0 35
wolffd@0 36 % Add output noise variance
wolffd@0 37 cov = covp + (net.min_noise + exp(net.noise))*eye(ndata);
wolffd@0 38