annotate toolboxes/distance_learning/mlr/metricPsi/metricPsiPO.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function S = metricPsiPO(q, y, n, pos, neg)
wolffd@0 2 %
wolffd@0 3 % S = metricPsiPO(q, y, n, d, pos, neg)
wolffd@0 4 %
wolffd@0 5 % q = index of the query point
wolffd@0 6 % y = the ordering to compute
wolffd@0 7 % n = number of points in the data set
wolffd@0 8 % pos = indices of relevant results for q
wolffd@0 9 % neg = indices of irrelevant results for q
wolffd@0 10 %
wolffd@0 11 % S is the vector of weights for q
wolffd@0 12
wolffd@0 13 yp = ismember(y, pos);
wolffd@0 14 NumPOS = sum(yp);
wolffd@0 15 PosAfter = NumPOS - cumsum(yp);
wolffd@0 16
wolffd@0 17 yn = ~yp;
wolffd@0 18 NumNEG = sum(yn);
wolffd@0 19 NegBefore = cumsum(yn) - yn;
wolffd@0 20
wolffd@0 21 S = zeros(n,1);
wolffd@0 22
wolffd@0 23 S(y) = 2 * (yp .* NegBefore - yn .* PosAfter) / (NumNEG * NumPOS);
wolffd@0 24
wolffd@0 25 end