function beta = my_rank_estimate(X,Y)

%  ranking(Y,X,X\Y)
beta = fminsearch(@(b) ranking(Y,X,b), X\Y);


function [current_sum,current_rank, current_idx] = ranking(Y,X,b)

[current_rank, current_idx]=find(Y-X*b);
current_sum=sum( (current_rank-(length(Y)+1)/2).*(Y(current_idx)-X(current_idx,:)*b))/length(Y);