All problems
Baum-Welch Gamma Step
Problem
Compute the Baum-Welch E-step state posteriors gamma for one time step: gamma[i] = alpha[i] * beta[i] / sum over j of alpha[j] * beta[j], where alpha and beta are the forward and backward probabilities.
Return a zero vector when the total is zero.
Hint
Gamma is the normalized product of the forward and backward messages.
Test cases
case 1
in: [[0.5,0.5],[0.4,0.6]]
expected: [0.4,0.6]
case 2
in: [[1,2,3],[1,1,1]]
expected: [0.16666666666666666,0.3333333333333333,0.5]
case 3
in: [[0,0],[1,1]]
expected: [0,0]
case 4
in: [[2,1],[3,3]]
expected: [0.6666666666666666,0.3333333333333333]
Starter codePython
def baum_welch_gamma(alpha, beta):
# Your code here
pass4 test cases · run your code against them in the editor