Home > . > prt_comp_ranking_dist.m

prt_comp_ranking_dist

PURPOSE ^

Function to compute the distance between two ranking vectors, as detailed

SYNOPSIS ^

function dr=prt_comp_ranking_dist(v,w)

DESCRIPTION ^

 Function to compute the distance between two ranking vectors, as detailed
 in Lampel and Moran, 2005 (in Information Retrieval, 8, 245-264).
 
 INPUT : two ranking vectors of the same size
 OUTPUT: their distance
_______________________________________________________________________
 Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function dr=prt_comp_ranking_dist(v,w)
0002 % Function to compute the distance between two ranking vectors, as detailed
0003 % in Lampel and Moran, 2005 (in Information Retrieval, 8, 245-264).
0004 %
0005 % INPUT : two ranking vectors of the same size
0006 % OUTPUT: their distance
0007 %_______________________________________________________________________
0008 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0009 
0010 % Written by Jessica Schrouff, 18/10/2012
0011 
0012 if nargin<2
0013     error('prt_comp_ranking_dist:nargin',...
0014         'two ranking vectors should be entered, please correct')
0015 end
0016 nr=length(v);
0017 
0018 if nr~=length(w)
0019     error('prt_comp_ranking_dist:sizeerror',...
0020         'the ranking vectors do not have the same size, please correct')
0021 end
0022 
0023 % Compute the distance
0024 dr=0;
0025 for i=1:nr
0026     for j=1:nr
0027         if (v(i)<v(j) && w(i)>w(j)) 
0028             tmp=1;
0029         else
0030             tmp=0;
0031         end
0032         dr=dr+tmp;
0033     end
0034 end
0035 dr=2*dr/(nr*(nr-1));
0036 
0037 end

Generated on Tue 10-Feb-2015 18:16:33 by m2html © 2005