attachment:dcor_dc.m of Geerligs_DistCor - MRC CBU Imaging Wiki
location: attachment:dcor_dc.m of Geerligs_DistCor

Attachment 'dcor_dc.m'

Download

   1 function [R] = dcor_dc(X,Y)
   2 % [R] = dcor_dc(X,Y)
   3 % Computes the double centered distance correlation between X and Y. 
   4 % Rows represent the examples, and columns the variables.
   5 
   6 % Based on: http://www.mathworks.com/matlabcentral/fileexchange/49968-dcorr--x--y--
   7 % and, the R package energy and papers by Szekely and Rizzo (2007; 2013 and 2014). 
   8 
   9 % Author: Linda Geerligs (lindageerligs@gmail.com), Date: 22-10-2015
  10 
  11 a = pdist2(X, X);
  12 b = pdist2(Y, Y);
  13 n=size(X,1);
  14 
  15 A = Dcenter(a);
  16 B = Dcenter(b);
  17 
  18 dcovXY = sum(sum(A.*B)) ./ (n.^2);
  19 dvarX = sum(sum(A.*A)) ./ (n.^2);
  20 dvarY = sum(sum(B.*B)) ./ (n.^2);
  21 
  22 R=sqrt(dcovXY / sqrt(dvarX * dvarY));
  23 
  24     function A=Dcenter(a) 
  25         A = a - bsxfun(@plus,mean(a),mean(a,2))+mean(a(:));
  26     end
  27 
  28 end

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2016-03-24 17:04:27, 41119.6 KB) [[attachment:Example_script.zip]]
  • [get | view] (2016-03-24 16:49:34, 0.7 KB) [[attachment:dcor_dc.m]]
  • [get | view] (2016-03-24 16:48:42, 1.1 KB) [[attachment:dcor_uc.m]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.