
function [prob]=wsirtcdf(T, n)
% 
if T < 0  
    prob=0;
 

elseif T >  n*(n+1)/2 
    prob = 1;
  
 
 elseif T >= 0 && T <=  n*(n+1)/2 
    if n <= 100 
    syms t
%
%probability generating function
     a=2^(-n)* prod( 1+t.^(1:n));
     co = coeffs(expand(a));
    prob = double(sum(co(1:T+1))); %exact...+1 added since co starts with 0, not 1
else  
prob = normcdf(T+1+0.5, n*(n+1)/4,  sqrt(n*(n+1)*(2*n+1)/24)); %normal approximation
    end
    else 
        error('Wrong alternative code. Input "alt" should be either 0, -1, or 1.')
end
end
    
    


