function [a,fval,P] = nolin_a(M,y,hyp) % NOLIN_A Calculates the hyperparameter value of 'a', exact final % function evaluation value of the log-likelihood function and the % normalised covariance matrix. % % [A,FVAL,P] = NOLIN_A(M,y,hyp) % % This function calculates the hyper-paramter value of 'a' from the % optimised lengthscales {g1,g2,...,gd} and noise {v} hyperparameters. In % addition, it also returns the function evaluation of the negative % log-likelihood function of the Gaussian process prior models, given by, % % fval = log(det(Q)) + y'*inv(Q)*y % % and the normalised covariance matrix, P, where Q = a*P, with the prior % covariance function (of Q) is of the form, % % C(zi,zj) = a*{exp([zi-zj]'*D*[zi-zj]) + v} % % Inputs: % M = Input explanatory variable, of dimension {N0 x D0} % y = Outcome (vector) from every input of the explantory variable % hyp = Hyperparameters, [a g1 g2 ... gd v], D=diag{g1,g2,...,gd} % % Outputs: % A = Hyperparameter value of "a" % FVAL = Function value evaluation % P = Covariance matrix % % % (C) Gaussian Process Toolbox 1.0 % (C) Copyright 2005-2007, Keith Neo % http://www.hamilton.ie [N0,L0]=size(M); g=hyp(1:L0); v=hyp(L0+1); expT=repmat(permute(M,[1,3,2]),[1,N0,1])-repmat(permute(M',[3,2,1]),[N0,1,1]); P=diag_add(exp(-0.5*sum((expT.^2).*repmat(permute(g,[3 2 1]),[N0,N0,1]),3)),v,N0); a=y'*(P\y)/N0; clear expT [cholC,pp]=chol(P); if pp==0, logdet=2*sum(log(diag(cholC))); else logdet=sum(log(svd(P))); end fval=N0+N0*log(a)+logdet; function Q=diag_add(Q,v,N0) for pp=1:N0 Q(pp,pp)=Q(pp,pp)+v; end