Daniel@0: function S = metricPsiPO(q, y, n, pos, neg) Daniel@0: % Daniel@0: % S = metricPsiPO(q, y, n, d, pos, neg) Daniel@0: % Daniel@0: % q = index of the query point Daniel@0: % y = the ordering to compute Daniel@0: % n = number of points in the data set Daniel@0: % pos = indices of relevant results for q Daniel@0: % neg = indices of irrelevant results for q Daniel@0: % Daniel@0: % S is the vector of weights for q Daniel@0: Daniel@0: yp = ismember(y, pos); Daniel@0: NumPOS = sum(yp); Daniel@0: PosAfter = NumPOS - cumsum(yp); Daniel@0: Daniel@0: yn = ~yp; Daniel@0: NumNEG = sum(yn); Daniel@0: NegBefore = cumsum(yn) - yn; Daniel@0: Daniel@0: S = zeros(n,1); Daniel@0: Daniel@0: S(y) = 2 * (yp .* NegBefore - yn .* PosAfter) / (NumNEG * NumPOS); Daniel@0: Daniel@0: end