SHARE
TWEET

Untitled

a guest Jan 12th, 2017 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %   X: data matrix, each row is one observation, each column is one feature
  2. %   D: pair-wise distance matrix
  3.  
  4. %   Copyright by Quan Wang, 2011/05/10
  5. %   Please cite: Quan Wang. Kernel Principal Component Analysis and its
  6. %   Applications in Face Recognition and Active Shape Models.
  7. %   arXiv:1207.3538 [cs.CV], 2012.
  8.  
  9. function D=distanceMatrix(X)
  10.  
  11. N=size(X,1);
  12.  
  13. XX=sum(X.*X,2);
  14. XX1=repmat(XX,1,N);
  15. XX2=repmat(XX',N,1);
  16.  
  17. D=XX1+XX2-2*(X*X');
  18. D(D<0)=0;
  19. D=sqrt(D);
  20.  
  21. %% FROM DEMO
  22.  
  23. DIST=distanceMatrix(train_x);
  24. DIST(DIST==0)=inf;
  25. DIST=min(DIST);
  26. para=5*mean(DIST);
RAW Paste Data
Top