function [ALFA,Ptot]=GetAlfa(O,A,MI,SIGMA);

[P,T]=size(O);
N=size(A,1);
ALFA=zeros(N,T);
NORMA=zeros(1,T);

ALFA(1,1) = 1;
for j=2:(N-1),
   suma = A(1,j);
   emis = normal (O(:,1), MI(:,j), SIGMA(:,j));
   ALFA(j,1)=suma*emis;
end
NORMA(1)=max(ALFA(:,1));
ALFA(:,1) = ALFA(:,1) / NORMA(1);

for t=2:T,
  for j=2:(N-1),
    suma =  sum ( ALFA(2:(N-1),t-1).*A(2:(N-1),j) ) ;
    emis =  normal (O(:,t), MI(:,j), SIGMA(:,j));
    ALFA(j,t) = suma * emis;
  end
  NORMA(t)=max(ALFA(:,t));
  if t~=T,
    ALFA(:,t) = ALFA(:,t) / NORMA(t);
  end
end

suma = sum ( ALFA(2:(N-1),T).*A(2:(N-1),N) );
ALFA(N,T) = suma;
NORMA(T)=max(ALFA(:,T));
ALFA(:,T) = ALFA(:,T) / NORMA(T);

PNA=zeros(1,T);
for t=1:T,
  PNA(t) = prod(NORMA(1:t));
end

Ptot=PNA(T) * ALFA(N,T);

ALFA=ones(N,1) * PNA .* ALFA;





















