kpca_matrix.m

来自「KPCA是一种非线性的盲源分离方法」· M 代码 · 共 40 行

M
40
字号
function psi = kpca_matrix(sv,x,kernel);
%KPCA_MATRIX calculates the kernel matrix.
%
% usage
%     psi = kpca_matrix(sv,x,kernel);
%
% input
%     sv       list of column vectors from the input space
%     x        list of column vectors from input space
%     kernel   a chosen kernel, e.g. 
%              {'gaussian',1}  Gaussian kernel with width 1
%              {'polynomial',3,5}  Polynomial kernel of degree 3
%                                  and with offset 5
%
% STH * 15AUG2001

switch kernel{1}
 case 'polynomial'
  d = kernel{2};
  theta = kernel{3};
  psi = ((sv' * x) + theta).^d;
 case 'gaussian' % Gaussian RBF
  c = kernel{2};
  dim = size(sv,2);
  T   = size(x,2);
  psi = zeros(dim,T);
  for di=1:dim
    %      fprintf('di=%d/%d \r',di,dim)
    diff = repmat(sv(:,di),[1 T]) - x;
    psi(di,:) = exp(-sum(diff.*diff,1)/c);
  end
  %    fprintf('\n')
  clear diff di
  otherwise
    error('kpca_matrix: the chosen kernel is not known, type "type map"')
end



⌨️ 快捷键说明

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