# Step training Baum-welch HMM

Referred to Baum–Welch algorithm, http://cs.au.dk/~cstorm/courses/MLiB_f14/slides/hidden-markov-models-4.pdf Is this formula correct? I spend a couple days to figure out which part is wrong.

I'm trying to train many of sequences. Each sequence are numbers(1,2,3,4) which has length = 6.

First, in the E-Step, I do forwards and backwards to calculate

$\gamma (N * totalState * lengthOfSequence)$

and

$\xi(N * totalPossiblelInput * totalState * totalState)$

$\gamma = forward(t) * backward(t)$/ normalize (sum of each same $t = 1$)

$\xi_{ij}(t) = \alpha_i(t) * A(i,j) * \beta_j(t+1) * B_j(t+1)$/ normalize (sum of each same t = 1)

For M-Step, I just put everything follow the above equation, update A, B, $\pi$.

The question is.... is my step correct?

When I train it, it converge very fast and stop very fast. (4-5 iterations) At first, I think that is a local minimum, but I use the same initial weights with MATLAB hmmtrain, It turned out that my code is wrong.