Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
farhadabedinzadeh authored Oct 6, 2022
1 parent b8fdecb commit e774014
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cvi/proximity/cosdist.m
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;
4 changes: 4 additions & 0 deletions cvi/proximity/lapdist.m
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);
21 changes: 21 additions & 0 deletions cvi/proximity/medist.m
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 added cvi/proximity/mtimesx.mexmaci64
Binary file not shown.
7 changes: 7 additions & 0 deletions cvi/proximity/neucdist.m
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));
5 changes: 5 additions & 0 deletions cvi/proximity/pcorr.m
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;
22 changes: 22 additions & 0 deletions cvi/proximity/proxconfig.m
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
8 changes: 8 additions & 0 deletions cvi/proximity/scorr.m
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;

0 comments on commit e774014

Please sign in to comment.