⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 covprod.m

📁 高斯过程在回归和分类问题中的应用
💻 M
字号:
function [A, B] = covProd(covfunc, logtheta, x, z);% covProd - compose a covariance function as the product of other covariance% functions. This function doesn't actually compute very much on its own, it% merely does some bookkeeping, and calls other covariance functions to do the% actual work.%% For more help on design of covariance functions, try "help covFunctions".%% (C) Copyright 2006 by Carl Edward Rasmussen, 2006-04-06.for i = 1:length(covfunc)                   % iterate over covariance functions  f = covfunc(i);  if iscell(f{:}), f = f{:}; end          % dereference cell array if necessary  j(i) = cellstr(feval(f{:}));endif nargin == 1,                                   % report number of parameters  A = char(j(1)); for i=2:length(covfunc), A = [A, '+', char(j(i))]; end  returnend[n, D] = size(x);v = [];              % v vector indicates to which covariance parameters belongfor i = 1:length(covfunc), v = [v repmat(i, 1, eval(char(j(i))))]; endswitch nargincase 3                                              % compute covariance matrix  A = ones(n, n);                       % allocate space for covariance matrix  for i = 1:length(covfunc)                   % iteration over factor functions    f = covfunc(i);    if iscell(f{:}), f = f{:}; end        % dereference cell array if necessary    A = A .* feval(f{:}, logtheta(v==i), x);             % multiply covariances  endcase 4                      % compute derivative matrix or test set covariances  if nargout == 2                                % compute test set cavariances    A = ones(size(z,1),1); B = ones(size(x,1),size(z,1));      % allocate space    for i = 1:length(covfunc)      f = covfunc(i);      if iscell(f{:}), f = f{:}; end      % dereference cell array if necessary      [AA BB] = feval(f{:}, logtheta(v==i), x, z);   % compute test covariances      A = A .* AA; B = B .* BB;                                % and accumulate    end  else                                            % compute derivative matrices    A = ones(n, n);    ii = v(z);                                      % which covariance function    j = sum(v(1:z)==ii);                   % which parameter in that covariance    for i = 1:length(covfunc)      f = covfunc(i);      if iscell(f{:}), f = f{:}; end      % dereference cell array if necessary      if i == ii        A = A .* feval(f{:}, logtheta(v==i), x, j);       % multiply derivative      else        A = A .* feval(f{:}, logtheta(v==i), x);          % multiply covariance      end    end  endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -