function f= f_rivalry(ss_l,ss_r,index,weight)

index=ss_l<0;
ss_l(index)=0;
index=ss_r<0;
ss_r(index)=0;

if index==1
    ss=ss_l;
else
    ss=ss_r;
end
f1= mean2(ss);
f2=var(ss(:));

ss=1-ss;
w=(1-weight)./weight;
ss=ss.*w;
f3=mean2(ss);
f4=var(ss(:));


f=[f1 f2 f3 f4];
% figure(2)
% hist(ss(:),[0:0.001:1])
% xlabel([' m:' num2str(f(1)),'  v:',num2str(f(2)),' score:' num2str(score)]);
% pause(1)
end