我只是想实现缩放的 Baum-Welch 算法,我遇到了一个问题,我的后向变量在缩放后超过了 1 的值。这正常吗?毕竟,概率不应该超过 1。
我正在使用从前向变量中获得的比例因子:
其中 c_t 是时间 t 的比例因子,alpha 是前向变量,s 是 hmm 中的状态。
对于后向算法,我在下面的 java 中实现了它:
public double[][] backwardAlgo(){
int time = eSequence.size();
double beta[][] = new double[2][time];
// Intialize beta for current time
for(int i = 0; i < 2; i++){
beta[i][time-1] = scaler[time-1];
}
// Use recursive method to calculate beta
double tempBeta = 0;
for(int t = time-2; t >= 0; t--){
for(int i = 0; i < 2; i++){
for(int j = 0; j < 2; j++){
tempBeta = tempBeta + (stateTransitionMatrix[i][j] * emissionMatrix[j][eSequence.get(t+1)] * beta[j][t+1]);
}
beta[i][t] = tempBeta;
beta[i][t] = scaler[t] * beta[i][t];
tempBeta = 0;
}
}
return beta;
}
比例存储在称为缩放器的数组中。这个嗯有2个状态。我还应该注意,我得到的比例因子也超过 1。