function [tau_plus,tau_minus,Ai,A_tau,Ai_plus,Ai_minus] = irrevers(y,tau,wind)
%y1=data1;
%y=price2ret(y1);%*(-1);
%y=y1;

%for ii=1:length(y1)-1
 %   y(ii)=y1(ii+1)-y1(ii);
 %end


%d=20;
%ta5u=20;
%wind=length(y);

%s=0.15;



    [p,ytau1,d]=verojatnost(tau,y);
    

%if (norma==0)
%    [p,ytau1]=verojatnost(tau,d,y);
%end


for ii=1:tau
            
    for jj=1:d
     if ytau1(ii,jj)>0
         if p(ii,jj)==0
             y_tau_plus(ii,jj)=0;
         else
             y_tau_plus(ii,jj)=((p(ii,jj)*log(p(ii,jj))));
         end
        y_tau_minus(ii,jj)=0;
        
    elseif ytau1(ii,jj)<=0
        if p(ii,jj)==0
            y_tau_minus(ii,jj)=0;
        else
            y_tau_minus(ii,jj)=((p(ii,jj)*log(p(ii,jj))));
        end
        y_tau_plus(ii,jj)=0;
    end
    end
    
    tau_plus(ii,1)=sum(y_tau_plus(ii,:));
    tau_minus(ii,1)=sum(y_tau_minus(ii,:));
     A_tau(ii,1)=(tau_plus(ii,1)-tau_minus(ii,1))/(tau_plus(ii,1)+tau_minus(ii,1));
     A_tau_plus(ii,1)=(tau_plus(ii,1));%/(tau_plus(ii,1)+tau_minus(ii,1));
     A_tau_minus(ii,1)=(tau_minus(ii,1));%/(tau_plus(ii,1)+tau_minus(ii,1));
end

   

Ai=mean(A_tau);
Ai_minus=mean(A_tau_minus);
Ai_plus=mean(A_tau_plus);
%Ai
%Ai_minus
%Ai_plus
