Given an observation {1,1,1,1,1,1,1,1,0}

Transition matrix$\,$A \begin{bmatrix} 0.5 & 0.5 \\ 0.3 & 0.7 \end{bmatrix}

Emission matrix$\,$B \begin{bmatrix} 0.3 & 0.7 \\ 0.8 & 0.2 \end{bmatrix}

Initial distribution$\,$B \begin{bmatrix} 0.2 & 0.8 \end{bmatrix}
After 600 iterations I have the following new distribution matrix$\:$A and matrix$\:$B:
matrix$\,$A \begin{bmatrix} 1 & 0 \\ 0.2418 & 0.7581 \end{bmatrix}

matrix$\,$B \begin{bmatrix} 0.1869 & 0.8130 \\ 0 & 1 \end{bmatrix}
Any Library or software can help me to check my own result because I am not sure if it is right


A surprisingly powerful check on whether there is an issue with your mathematical derivation of the Baum-Welch algorithm; or whether there is a bug in your implementation, is whether the log-likelihood monotonically increases during each iteration step of the algorithm. If your log-likelihood monotonically increases then the Baum-Welch algorithm is working as intended. If the log-likelihood decreases at any point, then you know with certainty that there is an issue with either your derivations, or your implementation in code.

That being said, just because Baum-Welch is working as intended may not necessarily mean that it is giving you the correct answer with respect to your own specific purposes.

As an example, depending on the distributional forms involved in your model (which I assume is a hidden Markov model), you may find that Baum-Welch may be sensitive to initial parameter guesses and find local maxima instead of a global maximum. Meaning that if you start with different parameter initialisations you get different final answers.

Depending on your context, using a local maximum out of many local maxima may be fine. However, if you are trying to use Baum-Welch for maximum likelihood estimation in the presence of latent variables (i.e. for a hidden Markov model), for which you do need a global maximum rather than a local maximum; then simply running Baum-Welch, getting a local maximum and using that will not be sufficient. Why? Because maximum-likelihood estimation requires that the (log)-likelihood be maximised. If you find yourself in this situation, one "implementational hack" to deal with this is to use multiple initialisations.

A more comprehensive way to really know if Baum-Welch is working appropriately for toy examples is to assume "true parameters" which you fix in advance, and then use that to generate synthetic data. If Baum-Welch can recover your "true parameters", then you know it's working correctly.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.