comparison toolboxes/FullBNT-1.0.7/netlab3.3/gpcovarf.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function covf = gpcovarf(net, x1, x2)
2 %GPCOVARF Calculate the covariance function for a Gaussian Process.
3 %
4 % Description
5 %
6 % COVF = GPCOVARF(NET, X1, X2) takes a Gaussian Process data structure
7 % NET together with two matrices X1 and X2 of input vectors, and
8 % computes the matrix of the covariance function values COVF.
9 %
10 % See also
11 % GP, GPCOVAR, GPCOVARP, GPERR, GPGRAD
12 %
13
14 % Copyright (c) Ian T Nabney (1996-2001)
15
16 errstring = consist(net, 'gp', x1);
17 if ~isempty(errstring);
18 error(errstring);
19 end
20
21 if size(x1, 2) ~= size(x2, 2)
22 error('Number of variables in x1 and x2 must be the same');
23 end
24
25 n1 = size(x1, 1);
26 n2 = size(x2, 1);
27 beta = diag(exp(net.inweights));
28
29 % Compute the weighted squared distances between x1 and x2
30 z = (x1.*x1)*beta*ones(net.nin, n2) - 2*x1*beta*x2' ...
31 + ones(n1, net.nin)*beta*(x2.*x2)';
32
33 switch net.covar_fn
34
35 case 'sqexp' % Squared exponential
36 covf = exp(net.fpar(1) - 0.5*z);
37
38 case 'ratquad' % Rational quadratic
39 nu = exp(net.fpar(2));
40 covf = exp(net.fpar(1))*((ones(size(z)) + z).^(-nu));
41
42 otherwise
43 error(['Unknown covariance function ', net.covar_fn]);
44 end