function [cost] = ndcg(rel)
%NDCG Summary of this function goes here
%   Detailed explanation goes here
L=10 %truncation level

res = 0;
len = size(rel,1);
if(len > L)
        T=L;
else
    T=len;
end;

for i=1:T
    res=res+(2^rel(i,2)-1)/log(1+i);
end;

%compute normalization constant
tmp = sortrows(rel(1:T,1:2),-2);
norm = 0;
for i=1:T
    norm=norm+(2^tmp(i,2)-1)/log(1+i);
end;

cost=res/norm;
end