Assignment

Given a sequence of emitted symbols x = x1 ... xn in an alphabet A, generated by a k-state HMM with unknown transition and emission probabilities, initial Transition and Emission matrices and a number of iterations i.

Return a matrix of transition probabilities Transition and a matrix of emission probabilities Emission that maximizes Pr(x, π) over all possible transition and emission matrices and over all hidden paths π.

Example

>>> viterbi_learning(100, 'yxzxx', 'xyz', 'AB', [[0.25781580389085273, 0.7421841961091472], [0.6220502902227053, 0.3779497097772947]], [[0.12871281587685687, 0.3979475788763271, 0.47333960524681606], [0.37116304784709164, 0.49694631193715255, 0.13189064021575572]])
([[0.0, 1.0], [0.5, 0.5]], [[0.0, 0.5, 0.5], [1.0, 0.0, 0.0]])

>>> viterbi_learning(100, 'yyyyzyxxxy', 'xyz', 'AB', [[0.6363288730737235, 0.3636711269262765], [0.8227420316709164, 0.17725796832908358]], [[0.19260689091885078, 0.46803753463950304, 0.33935557444164605], [0.3434626106351156, 0.5464619476773515, 0.11007544168753285]])
([[0.7142857142857143, 0.2857142857142857], [1.0, 0.0]], [[0.125, 0.75, 0.125], [1.0, 0.0, 0.0]])