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

📄 covsum.m

📁 高斯过程在回归和分类问题中的应用
💻 M
字号:
function [A, B] = covSum(covfunc, logtheta, x, z);% covSum - compose a covariance function as the sum 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-03-20.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 = zeros(n, n);                       % allocate space for covariance matrix  for i = 1:length(covfunc)                  % iteration over summand functions    f = covfunc(i);    if iscell(f{:}), f = f{:}; end        % dereference cell array if necessary    A = A + feval(f{:}, logtheta(v==i), x);            % accumulate covariances  endcase 4                      % compute derivative matrix or test set covariances  if nargout == 2                                % compute test set cavariances    A = zeros(size(z,1),1); B = zeros(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    i = v(z);                                       % which covariance function    j = sum(v(1:z)==i);                    % which parameter in that covariance    f = covfunc(i);    if iscell(f{:}), f = f{:}; end        % dereference cell array if necessary    A = feval(f{:}, logtheta(v==i), x, j);                 % compute derivative  endend

⌨️ 快捷键说明

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