%genprob.m
function [prob]=genprob(seq,p11,p21,h11,h21)
s=1; 
prob=0;
for i=1:1:length(seq)
    if(seq(i)==1) 
        if(s==1)
            choice1=prob+log(p11)+log(h11);
            choice2=prob+log((1-p11))+log(h21);
        else
            choice1=prob+log(p21)+log(h11);
            choice2=prob+log((1-p21))+log(h21);
        end
    else
        if(s==1)
            choice1=prob+log(p11)+log((1-h11));
            choice2=prob+log((1-p11))+log((1-h21));
        else
            choice1=prob+log(p21)+log((1-h11));
            choice2=prob+log((1-p21))+log((1-h21));
        end
    end
    if(choice1>choice2) 
        prob=choice1;
        s=1;
    else
        prob=choice2;
        s=2;
    end
end
end