如何在没有任何内置函数的情况下编写Pearson Correlation的内核化版本?

时间:2018-11-15 08:27:31

标签: kernel correlation

我想计算Pearson相关性的内核化版本,因此我必须编写代码而不是使用corrcoef命令,根据公式,我必须分别编写cov和std,我为cov使用了点积技巧,当我正在将其用于std,结果不正确(this trick

实际上我的字体确切地知道如何输入内核(例如std中的Gaussian)

for i=1:p;
    one_vector(1:size(Signals{i,1},1)) = 1;
    mu = (one_vector * Signals{i,1}) / size(Signals{i,1},1);
    A_mean_subtract = Signals{i,1} - mu(one_vector, :);
    for j=1:116
        u=(A_mean_subtract(:,j));
        for z=1:116;
            v=(A_mean_subtract(:,z));
            r=sqrt(sum((u-v).^2));                   ---- cov in Gaussian form ( instead of u'*v) I put u and v in gaussian kernel formula
            gamma=1/(2*100^2);
            k=exp(-gamma*(r^2));
            covB(j,z) = k / (size(Signals{i,1},1) - 1);---- it is correct
              K_R(j,z)= covB(j,z)/sqrt((u'*u)*(v'*v);---- I know that I have to kernelized this part like above but before that the result is not correct in sipmle form (not kernelized) let alone kernel form
        end
    end

0 个答案:

没有答案