function [alpha1]=compute_alpha(observation,emmision,transmat)
D=[5 8  11  14  17 20];
I=[2 4  7   10  13 16  19];
M=[1 3  6   9   12 15  18  21];
observation=[21,observation];
T=length(observation);
Q=6;
alpha1=zeros((3*Q)+3,T);
alpha1(M(1),1)=1;
alpha1(M(2),2)=emmision(M(2),observation(2))*transmat(M(1),M(2));  
alpha1(M(3),2)=emmision(M(3),observation(2))*transmat(M(1),D(1))*transmat(D(1),M(3));
alpha1(M(4),2)=emmision(M(4),observation(2))*transmat(M(1),D(1))*transmat(D(1),D(2))*transmat(D(2),M(4));
alpha1(M(5),2)=emmision(M(5),observation(2))*transmat(M(1),D(1))*transmat(D(1),D(2))*transmat(D(2),D(3))*transmat(D(3),M(5));
alpha1(M(6),2)=emmision(M(6),observation(2))*transmat(M(1),D(1))*transmat(D(1),D(2))*transmat(D(2),D(3))*transmat(D(3),D(4))*transmat(D(4),M(6));
alpha1(M(7),2)=emmision(M(7),observation(2))*transmat(M(1),D(1))*transmat(D(1),D(2))*transmat(D(2),D(3))*transmat(D(3),D(4))*transmat(D(4),D(5))*transmat(D(5),M(7));
alpha1(I(1),2)=transmat(M(1),I(1))*emmision(I(1),observation(2));
alpha1(I(2),2)=transmat(M(1),D(1))*transmat(D(1),I(2))*emmision(I(2),observation(2));
alpha1(I(3),2)=transmat(M(1),D(1))*transmat(D(1),D(2))*transmat(D(2),I(3))*emmision(I(3),observation(2));
alpha1(I(4),2)=transmat(M(1),D(1))*transmat(D(1),D(2))*transmat(D(2),D(3))*transmat(D(3),I(4))*emmision(I(4),observation(2));
alpha1(I(5),2)=transmat(M(1),D(1))*transmat(D(1),D(2))*transmat(D(2),D(3))*transmat(D(3),D(4))*transmat(D(4),I(5))*emmision(I(5),observation(2));
alpha1(I(6),2)=transmat(M(1),D(1))*transmat(D(1),D(2))*transmat(D(2),D(3))*transmat(D(3),D(4))*transmat(D(4),D(5))*transmat(D(5),I(6))*emmision(I(6),observation(2));
alpha1(I(7),2)=transmat(M(1),D(1))*transmat(D(1),D(2))*transmat(D(2),D(3))*transmat(D(3),D(4))*transmat(D(4),D(5))*transmat(D(5),D(6))*transmat(D(6),I(7))*emmision(I(7),observation(2));
alpha1(D(1),2)=alpha1(I(1),2)*transmat(I(1),D(1));
for k=2:Q
   alpha1(D(k),2)=alpha1(M(k),2)*transmat(M(k),D(k))+alpha1(I(k),2)*transmat(I(k),D(k))+alpha1(D(k-1),2)*transmat(D(k-1),D(k));
end
for i=3:T
          alpha1(I(1),i) = transmat(I(1),I(1))*emmision(I(1),observation(i))*alpha1(I(1),i-1);
          alpha1(D(1),i) = transmat(I(1),D(1))*alpha1(I(1),i);
      for k=2:(Q+1)
         if k==2
           alpha1(M(k),i)=emmision(M(k),observation(i))* alpha1(I(k-1),i-1)*transmat(I(k-1),M(k));
         else
           alpha1(M(k),i)=emmision(M(k),observation(i))*[alpha1(M(k-1),i-1)*transmat(M(k-1),M(k))+ alpha1(I(k-1),i-1)*transmat(I(k-1),M(k))+alpha1(D(k-2),i-1)*transmat(D(k-2),M(k))];
         end
         alpha1(I(k),i)=emmision(I(k),observation(i))*[alpha1(M(k),i-1)*transmat(M(k),I(k))+ alpha1(I(k),i-1)*transmat(I(k),I(k))+alpha1(D(k-1),i-1)*transmat(D(k-1),I(k))];
         if k~=(Q+1)
             alpha1(D(k),i)=alpha1(M(k),i)*transmat(M(k),D(k))+ alpha1(I(k),i)*transmat(I(k),D(k))+alpha1(D(k-1),i)*transmat(D(k-1),D(k));
        end
      end
end
alpha1=alpha1(:,2:T);
observation=observation(2:T);
T=length(observation);
