function y = GD2016_Figure3()
    dat=xlsread('samplingcombinedmatlab1.xlsx'); 
    seenm=0;
    seenl=0;
    seenh=0;
    filterdat = zeros(18113,19);
    forplot = zeros(134,3);
    i=1;
    l = 2;
    m=l;
    n=1;
    while i<=2370
        while((dat(l,6)==dat(l-1,6)) && (dat(l,1)==dat(l-1,1)) && (dat(l,5)==dat(l-1,5)))
            if dat(l-1,8) == dat(l-1,10)
                seenm=1;
            end;    
            if dat(l-1,8) == dat(l-1,11)
                seenh=1;
            end;
            if dat(l-1,8) == dat(l-1,12)
                seenl=1;            
            end;
            l=l+1;
            if l == 31261
                break;
            end;    
        end;
            if (dat(l-1,8) == dat(l-1,10))
                seenm=1;
            end;
            if (dat(l-1,8) == dat(l-1,11))
                seenh=1;
            end;    
            if (dat(l-1,8) == dat(l-1,12))
                seenl=1;            
            end;
          if (seenm+seenh+seenl==3)
                maxpay =0;
                u=0;
                minpay =0;
                v=0;
              for d=m-1:l-1
                filterdat(n,1) = dat(d,1);
                filterdat(n,2) = dat(d,2);
                filterdat(n,3) = dat(d,3);
                filterdat(n,4) = dat(d,4);
                filterdat(n,5) = dat(d,5);
                filterdat(n,6) = dat(d,6);
                filterdat(n,7) = dat(d,7);
                filterdat(n,8) = dat(d,8);
                filterdat(n,9) = dat(d,9);
                filterdat(n,10) = dat(d,10);
                filterdat(n,11) = dat(d,11);
                filterdat(n,12) = dat(d,12);
                filterdat(n,13) = dat(d,13);
                evsure = filterdat(n,10);
                evrisky = filterdat(n,11)*filterdat(n,13)+filterdat(n,12)*(1-filterdat(n,13));
                if ((evrisky > evsure) && filterdat(n,7) == 1) || ((evrisky < evsure) && filterdat(n,7) == 0)  
                    max = 1;
                else
                    max =0;
                end;
                filterdat(n,14) = max;
                
                if filterdat(n,3) ~= 1
                    if filterdat(n-1,14) ~= filterdat(n,14)
                        filterdat(n,15) = 1;
                    else
                        filterdat(n,15) = 0;
                    end;                    
                end;
                filterdat(n,16) = (l-1)-(m-1)+1;
                filterdat(n,17) = -1000;
                filterdat(n,18) = -1000;
                if filterdat(n,14) == 1 
                   if  filterdat(n,3) == 1
                    maxpay = filterdat(n,8);
                   else
                    maxpay = maxpay+filterdat(n,8);
                   end;
                   u=u+1;
                   filterdat(n,17) = maxpay/u;
                    if n>1 && filterdat(n,6) == filterdat(n-1,6) && filterdat(n,1) == filterdat(n-1,1) && filterdat(n,5) == filterdat(n-1,5)
                       filterdat(n,18) = filterdat(n-1,18);
                    end;   
                else
                   if  filterdat(n,3) == 1
                    minpay = filterdat(n,8);
                   else
                    minpay = minpay+filterdat(n,8);
                   end;
                   v=v+1;
                   filterdat(n,18) = minpay/v;
                    if n>1 && filterdat(n,6) == filterdat(n-1,6) && filterdat(n,1) == filterdat(n-1,1) && filterdat(n,5) == filterdat(n-1,5)
                       filterdat(n,17) = filterdat(n-1,17);
                    end;
                end; 
                if(filterdat(n,17) ~= -1000 && filterdat(n,18) ~= -1000)
                    if filterdat(n,17) >= filterdat(n,18)
                        filterdat(n,19) = 1;
                    else
                        filterdat(n,19) = 0;
                    end;    
                else
                    filterdat(n,19) = -1000;
                end;
                n=n+1;
              end;    
          end;    
          seenm = 0;
          seenh = 0;
          seenl = 0;
          i = i + 1;
          l=l+1;
          m=l;
    end;
xlswrite('filterdata.xlsx',filterdat);
l=2;
i=1;
m=0;
summax=0;
sumalt=0;
sumeevmax=0;
n=0;
for t = 1:134
   while i <= 988
    while((filterdat(l,6)==filterdat(l-1,6)) && (filterdat(l,1)==filterdat(l-1,1)) && (filterdat(l,5)==filterdat(l-1,5)))
       if l == 18113
           break;
       end;   
      if filterdat(l-1,3) == t
        summax = summax+filterdat(l-1,14);
        sumalt = sumalt+filterdat(l-1,15);
        m=m+1;
        if filterdat(l-1,19) ~= -1000
           sumeevmax = sumeevmax+filterdat(l-1,19);
           n=n+1;
        end;    
      end;  
        l=l+1;
    end;
    l=l+1;
    i=i+1;
   end; 
   forplot(t,1) = summax/m;
   forplot(t,2) = sumalt/m;
   forplot(t,3) = sumeevmax/n;
l=2;
i=1;
m=0;
summax=0;
sumalt=0;
sumeevmax=0;
n=0;
end;
x = [1:1:134];
y1 = forplot(x,1);
y2 = forplot(x,2);
y3 = forplot(x,3);
plot(x,y1,x,y2,x,y3), xlabel('samples'), ylabel('Sampling-H'), title('Alternations and Maximization based upon EV and EEV')
y=1;
 
 
 
   
    
   