-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8fdecb
commit e774014
Showing
8 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function D = cosdist(A,B) | ||
% D = bsxfun(@plus,0.5*dot(B,B,1),0.5*dot(A,A,1)') - mtimesx(A,'T',B); | ||
D = bsxfun(@plus,0.5*dot(B,B,1),0.5*dot(A,A,1)') - A'*B; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function D = lapdist(A,B) | ||
De = bsxfun(@plus,dot(B,B,1),dot(A,A,1)') - 2*(A'*B);%mtimesx(A,'T',B); | ||
cosAB = 1 - 0.5*De; | ||
D = (1-cosAB)./(1+cosAB); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function GXX = medist(DXX) | ||
|
||
% Construccion del grafo no dirigido (triangulo inferior de DXX) | ||
LXX = tril(DXX); | ||
UG = sparse(LXX); | ||
% Encontrar el arbol de recubrimiento minimo | ||
[MST,~] = graphminspantree(UG); | ||
|
||
nVertex = length(MST); | ||
MED = zeros(nVertex); | ||
for i = 1:nVertex; | ||
for j = i+1:nVertex | ||
[~,path,~] = graphshortestpath(MST,i,j,'directed',false); | ||
v_i = path(1:end-1); % Vertex i | ||
v_j = path(2:end); % Vertex j | ||
subMST = MST(v_i,v_j) + MST(v_j,v_i); % Subgraph of MST | ||
[~,~,distances] = find(subMST); | ||
MED(i,j) = max(distances); % MED distance from subgraph of MST | ||
end | ||
end | ||
GXX = MED + MED'; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function D = neucdist(A, B) | ||
A = bsxfun(@minus,A,mean(A,2)); | ||
B = bsxfun(@minus,B,mean(B,2)); | ||
A = bsxfun(@rdivide,A,std(A,0,2)); | ||
B = bsxfun(@rdivide,B,std(B,0,2)); | ||
% D = sqrt(bsxfun(@plus,dot(B,B,1),dot(A,A,1)')- 2*mtimesx(A,'T',B)); | ||
D = sqrt(bsxfun(@plus,dot(B,B,1),dot(A,A,1)')- 2*(A'*B)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function D = pcorr(A,B) | ||
A = bsxfun(@minus,A,mean(A,2)); | ||
B = bsxfun(@minus,B,mean(B,2)); | ||
% D = bsxfun(@plus,0.5*dot(B,B,1),0.5*dot(A,A,1)') - mtimesx(A,'T',B); | ||
D = bsxfun(@plus,0.5*dot(B,B,1),0.5*dot(A,A,1)') - A'*B; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function fun = proxconfig(opt) | ||
if strcmpi(opt,'euc') | ||
% Euclidean distance | ||
fun = @eucdist; | ||
elseif strcmpi(opt,'neuc') | ||
% Normalized Euclidean distance | ||
fun = @neucdist; | ||
elseif strcmpi(opt,'cos') | ||
% Cosine similarity | ||
fun = @cosdist; | ||
elseif strcmpi(opt,'pcorr') | ||
% Pearson's correlation coefficient | ||
fun = @pcorr; | ||
elseif strcmpi(opt,'scorr') | ||
% Spearman's correlation coefficient | ||
fun = @scorr; | ||
elseif strcmpi(opt,'lap') | ||
% Laplacian distance | ||
fun = @lapdist; | ||
else | ||
error('Unknown proximity measure'); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function D = scorr(~,B) | ||
global Xrank; | ||
A = Xrank; % A = ranking(A); | ||
B = ranking(B); | ||
A = bsxfun(@minus,A,mean(A,2)); | ||
B = bsxfun(@minus,B,mean(B,2)); | ||
% D = bsxfun(@plus,0.5*dot(B,B,1),0.5*dot(A,A,1)') - mtimesx(A,'T',B); | ||
D = bsxfun(@plus,0.5*dot(B,B,1),0.5*dot(A,A,1)') - A'*B; |