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