我把这个放在stackoverflow而不是math.stackexchange,因为我正在尝试编程方法而不是数学方法。
我有3个矩阵,一个转换trans
,一个发射emiss
(或观察错误)和一个州state
。
为此,我还有一系列观察obs
我的方法很简单:
prob = 1 # Probability of sequence is 1 to start with
for o in obs: # For each observation:
p_mult = dot(emiss, state) # Get the probability of each observation,
p_mult = p_mult.get_elem(o)# select the corresponding observation
prob = prob * p_mult # and multiply that with the total probability
state = dot(trans, state) # Last, change the state using the transition matrix
print(prob) # Print answer
其中dot(x,y)
是两个矩阵(例如{1x4}*{4x3}->{1x3}
)和x.get_elem(y)
的点积,它取向量y
的{{1}}元素。
由于某些原因,这似乎不起作用,因为我计算的概率与其他概率不匹配。有人能给我一些这个推理的错误吗?